Quickstart
Use this guide to run CairnCMS locally, create a simple collection, add one record, and fetch it through the API.
This quickstart uses the cairncms init scaffold. It is the fastest way to get a working local instance with Docker Compose, a generated .env, and an admin account.
This guide is for local development. It is not a production deployment guide.
Requirements
Section titled “Requirements”Before you start, make sure you have:
- Docker with Compose v2
- Node 22 or newer if you want to use the generated
npm start,npm stop, andnpm logsshortcuts
Create a local project
Section titled “Create a local project”Run the init command:
npx cairncms init my-cmsThis command:
- creates a new
my-cms/directory - writes the Docker Compose files into
my-cms/cairncms/ - generates random secrets and an admin password in
my-cms/cairncms/.env - starts the stack by default
When the command finishes, it prints:
- the local URL, usually
http://localhost:8055 - the admin email, which defaults to
admin@example.com - the generated admin password
If you only want the files and do not want to start the stack yet, use:
npx cairncms init my-cms --no-startSign in to the app
Section titled “Sign in to the app”Open the local URL in your browser:
http://localhost:8055Sign in with:
- Email:
admin@example.com - Password: the password printed by
cairncms init
If you lose the password, you can read it from my-cms/cairncms/.env.
Create a collection
Section titled “Create a collection”Create a simple collection called articles.
- Open Settings > Data Model.
- Create a new collection.
- Set the collection name to
articles. - Keep the default options for now and save it.
At this point, CairnCMS has created the underlying database table for the collection.
Add a field
Section titled “Add a field”Add a text field called title.
- Stay in Settings > Data Model and open the
articlescollection. - Create a new field.
- Use
titleas the field key. - Keep the default string input settings and save.
Create a record
Section titled “Create a record”Now add one record through the app.
- Switch to the Content module.
- Open the
articlescollection. - Create a new record.
- Set
titletoHello World. - Save the record.
You now have content in the database and a collection the API can query.
Allow temporary public read access
Section titled “Allow temporary public read access”By default, new content is not public. For the quickest first API request, grant the built-in Public role read access to the articles collection.
- Open Settings > Roles & Permissions.
- Open the Public role.
- Find the
articlescollection. - Allow read access for that collection.
- Save the change.
Make your first API request
Section titled “Make your first API request”Now open the collection endpoint directly in your browser:
http://localhost:8055/items/articlesYou can also request it with curl:
curl -sS http://localhost:8055/items/articlesYou’ll get a JSON response like this:
{ "data": [ { "id": 1, "title": "Hello World" } ]}Revoke public access
Section titled “Revoke public access”The public read permission in this guide is only there to make the first API request easy to verify.
When you are done testing it:
- Go back to Settings > Roles & Permissions > Public.
- Remove the
readpermission fromarticles. - Save the change.
What you have now
Section titled “What you have now”At this point you have:
- a local CairnCMS instance running in Docker
- a collection backed by a real SQL table
- one saved record
- a working API request against a real collection
Stop and restart the stack
Section titled “Stop and restart the stack”From the project directory:
npm stopnpm startIf you prefer not to use the npm shortcuts, run Docker Compose directly:
docker compose --project-directory cairncms -f cairncms/docker-compose.yml up -ddocker compose --project-directory cairncms -f cairncms/docker-compose.yml downNext steps
Section titled “Next steps”Once the quickstart works, the next useful areas are:
- the app itself: create more collections, fields, and relationships
- permissions: decide what should be public and what should stay authenticated
- authentication: for real applications, authenticate requests with a token instead of exposing collections through the Public role
- the API: try schema and config snapshots in
my-cms/README.md - deployment: move on to the deployment docs when you are ready for a non-local setup