CLI reference
Every areca command and flag, the environment variables each command reads, exit codes, and the quirks to know before you script it.
The areca command comes with @areca-cms/site-sdk. It connects your site project to Areca: it creates the setup files, sends your content definitions to the CMS, and pulls published content for your build. Run it from the root of your site project, through your package manager (pnpm exec areca or a package.json script).
For a walkthrough, see Installation and Pulling content.
Commands
| Command | What it does | Reads |
|---|---|---|
areca init | Creates the config, environment and output files in a site project. | Flags, or prompts |
areca pull | Downloads the current publication into a folder. | ARECA_CMS_URL, ARECA_SITE_TOKEN |
areca manifest push | Sends the content definitions in areca.config.ts to the CMS. | ARECA_CMS_URL, ARECA_SCHEMA_TOKEN |
areca manifest pull | Writes the CMS's content definitions into areca.config.ts. | ARECA_CMS_URL, ARECA_SITE_TOKEN, ARECA_SITE_KEY (only without a config file) |
areca sync-manifest | Deprecated alias of areca manifest push. | Same as manifest push |
areca run -- | Runs another command with the environment loaded. | Nothing extra |
Run areca with no arguments, or areca --help, to print the usage text.
Global behavior
These rules apply to every command.
- Environment files load first. Before any command runs,
arecareads.env.local, then.env, from the current directory. A variable that is already set in the shell is never overwritten. Because.env.localloads first, it wins over.env. - Empty values count as set. If
.env.localcontainsARECA_SITE_TOKEN=, that empty value blocks a value for the same key in.env. - Empty arguments are ignored. Empty strings in the argument list are dropped before parsing.
- Errors go to stderr. A parse error prints the message and the full usage text to stderr and exits with code
1. A runtime error prints only its message to stderr. --helpworks only as the first argument.areca --helpandareca -hprint usage.areca pull --helpfails withUnknown argument: --help.- Unknown flags fail. Any argument a command does not recognize fails with
Unknown argument: <arg>. - A flag needs a value. The value is the next argument. If it is missing, or starts with
-, the command fails withMissing value for <flag>. For example,--token -abcis rejected.
Environment file format
.env.local and .env are read line by line:
- Blank lines and lines starting with
#are skipped. - Each line is split at the first
=. Spaces around the key and at the ends of the line are removed. Spaces inside the value are kept. - Matching double or single quotes around a value are removed.
- There is no
exportprefix support, no escape handling and no inline comments. - If a key appears twice in one file, the last value wins.
areca init
Sets up a site project for Areca. It writes the config file, an example env file, the local env file, and a generated content folder. It also adds two scripts to package.json.
areca init --cms-url https://cms.example.com --site-key acme-siteRun init in a terminal and omit --token. The command then prompts for the site token, which is masked. Only pass --token in a script where the value comes from a secret store.
| Flag | Type | Default | Description |
|---|---|---|---|
--cms-url <url> | string | Prompt: http://localhost:3000 | Base URL of your CMS. Must start with http:// or https://. Trailing slashes are removed. |
--token <token> | string | Prompt (masked) | The site token. See the quirk below. |
--site-key <key> | string | Prompt | The site key, shown in the CMS. Lowercase letters, digits and single hyphens, for example acme-site. |
--out <dir> | path | src/generated/content | Folder for the pulled content. |
--config <path> | path | areca.config.ts | Path of the config file to create. |
--assets-dir <dir> | path | Prompt: public/areca | Folder that areca pull copies media into. Relative to the project root. |
--assets-public-path <path> | string | Derived | URL path your site serves the media folder from. Needed only when the folder is not under public/. |
--no-assets | boolean | false | Keep media URLs pointing at the CMS. Cannot be combined with the two flags above. |
--yes, -y | boolean | false | Skip prompts. Missing --cms-url, --token or --site-key is then an error. |
--force | boolean | false | Overwrite the config file and .env.example if they exist. |
Interactive mode runs when --yes is not set and stdin is a terminal. The command prompts for each value you did not pass as a flag. After the site key it asks whether to download media into the repo (default yes) and which folder to use (default public/areca). For a folder outside public/ it also asks for the URL path that serves it. See local media.
Non-interactive mode runs otherwise. All three of --cms-url, --token and --site-key are then required.
Files written
Paths are relative to the current directory.
| File | Behavior |
|---|---|
areca.config.ts (or the --config path) | Created if missing, or with --force, with the assets settings and an empty collections object. If the file exists, init adds an assets block after siteKey when there is none. If there is one, the interactive prompt shows it and asks before replacing it; without a prompt it is kept unless you pass a media flag. When the file cannot be edited safely, init prints the block to paste. |
.env.example | Created only if missing, or with --force. Sets ARECA_CMS_URL to the CMS URL, and lists ARECA_SITE_TOKEN and ARECA_SCHEMA_TOKEN with empty values. It contains no secrets. |
.env.local | Always updated. Sets ARECA_CMS_URL and ARECA_SITE_TOKEN. Other lines are kept. |
.gitignore | Adds .env.local, <out>/* (the pulled files), !<out>/areca.gen.ts (so the generated types are committed) and the media folder, if they are not already listed. An older <out>/ line is replaced, because it would also hide the types file. Media is downloaded again by every pull, like the content. |
<out>/manifest.json | Created with empty values, so the folder exists before the first pull. |
package.json | Adds sync-manifest (areca manifest push) and content:pull (areca pull --out <out>) scripts if they are missing or blank. If dev exists and does not already use --env-file or areca run, it becomes areca run -- <dev command>. |
init must run in a folder with a package.json object. Otherwise it stops before writing anything.
Environment variables
init does not read ARECA_* variables from the shell. It takes its values from flags or prompts, then writes them to .env.local. Variables from .env.local and .env are still loaded first.
Quirks
--tokenleaves the secret in your shell history and process list. The value appears in your command history and inpsoutput while the command runs. Use the prompt instead. The SDK never prints the token..env.localkeeps the default file permissions. On a shared machine, other users may be able to read the token. See restrict the file permissions.- Symlinks are followed.
initwrites through a symlinked config or env file.
areca pull
Downloads the current publication from the CMS and writes one JSON file per collection. It also copies every image and file the content uses into your project, and points the content at those copies, so the built site never requests anything from the CMS. Your build reads these files. Run it before dev or build, and again whenever you publish.
areca pull --out src/generated/content| Flag | Type | Default | Description |
|---|---|---|---|
--out <dir> | path | src/generated/content | Folder for the output. Created if missing. Relative paths are resolved from the current directory. |
--publication <id> | string | Live publication | Pull this exact publication. ARECA_SNAPSHOT_ID does the same in go-live builds. |
--config <path> | path | areca.config.ts | Config file to read the assets settings from. Without this flag a missing file is fine and the defaults apply. |
--types <path> | path | <out>/areca.gen.ts | Where to write the generated types and content module. Relative paths are resolved from the current directory. |
The media settings come from assets in the config file: by default files go to public/areca and the content uses /areca/<file>. See local media.
The generated module is described in typed content.
Environment variables
| Variable | Required | Use |
|---|---|---|
ARECA_CMS_URL | Yes | CMS base URL. |
ARECA_SITE_TOKEN | Yes | Site token, sent as a bearer token. |
Output
On success it prints one line, for example:
Pulled publication pub_1 (abc123): articles=1, pages=0
Media: 12 file(s) in public/areca (3 downloaded)
Types: src/generated/content/areca.gen.tsThe counts use the camelCase collection keys, so a config key blog-posts prints as blogPosts. The Types: line shows where areca.gen.ts was written. Warnings, such as the one for a publication without an embedded schema, go to stderr after it.
The folders then contain:
src/generated/content/
areca.gen.ts the types and the content object (commit this)
manifest.json points at the current generation
.publications/
publication-Ab12Cd/
articles.json the entries of the articles collection
pages.json one file per collection
.assets.json the media files this generation uses
public/areca/
hero-banner-3f2a91c0.jpg one file per image or uploaded filemanifest.json has this shape:
{
"publicationId": "pub_1",
"hash": "abc123",
"createdAt": "2026-01-01T00:00:00.000Z",
"collections": { "articles": 1, "pages": 0 },
"generation": "publication-Ab12Cd",
"assets": { "publicPath": "/areca", "count": 12 }
}Each collection file is an array of entries. See Pulling content for the shape of an entry.
Quirks
- Each pull is a new generation. Files are written to a new folder under
.publications, thenmanifest.jsonswitches to it in one rename. A failed pull leaves the previous content in place. - Two older generations are kept. The current generation and the two before it stay, so a server that read an older
manifest.jsonkeeps working. Older generations are deleted, along with media files that only they used. Files in the media folder that no generation recorded, such as your own, are never deleted. - Media is all or nothing. If any file fails to download, the pull fails and nothing changes. Files already on disk are not downloaded again. The media folder must be inside the project.
- Cleanup does not fail a pull. Old generations are removed after the new one is live. If that fails, the pull still succeeds and prints a warning.
- Older CMS versions. If the CMS does not list media files, the pull prints a warning and keeps the CMS URLs.
- Collection names must be safe identifiers.
pullrefuses a collection whose key is not a safe identifier, before it writes any file. See identifier rules. - Entries are checked against the schema.
pullchecks every entry before it writes any file, and it refuses names that collide in camelCase. See what the pull checks. - Types follow the content.
areca.gen.tsis written after the new content is live. If the pull fails, the types stay as they were. - No publication, no output. If the site has never gone live, the command fails with the 404 message and writes nothing new. See Errors and limits.
areca manifest push
Sends the content definitions in your config file to the CMS. The CMS then creates or updates the collections for the site. Run it after you change areca.config.ts.
areca manifest push
areca manifest push ./areca.config.ts| Argument | Type | Default | Description |
|---|---|---|---|
[config] | path | ./areca.config.ts | The config file to read. Optional. |
--confirm-drop <collection.field> | string | none | Confirms the removal of one field that still holds content. Repeat it for each field. Use the raw collection or section key, for example articles.subtitle. |
--yes, -y | boolean | false | Confirms every field removal the CMS lists. |
The command loads the config file by importing it. That runs the file's code. Keep the config free of side effects.
For a TypeScript config, the command uses Node's native TypeScript import. If that import fails, the error suggests running the command through tsx, for example pnpm exec tsx ./node_modules/@areca-cms/site-sdk/dist/cli.js manifest push ./areca.config.ts.
Environment variables
| Variable | Required | Use |
|---|---|---|
ARECA_CMS_URL | Yes | CMS base URL. |
ARECA_SCHEMA_TOKEN | Yes | Schema token. Used for the push. It never falls back to the site token. A push does not need ARECA_SITE_TOKEN. |
The schema token is in Settings › Developer for the site. Keep it on the machine where you edit the schema. It should not be in a build's environment.
Removing fields
A field that still holds content cannot be removed silently. When a push would remove one, the CMS refuses it and the command lists each field with the number of entries that hold content for it:
This push removes fields that still hold content:
- articles.subtitle: 3 entries lose this field's contentThen the command:
- On a terminal, asks
Delete the content of articles.subtitle and push?, with No as the default. - Without a terminal, stops and tells you to re-run with
--confirm-drop articles.subtitlefor each field, or with--yes. - With
--yes, or with each field passed to--confirm-drop, pushes and deletes that content from every stored version of the entries, including translations.
Declining, or leaving a field unconfirmed, stops the command with an error and a non-zero exit code. Nothing is pushed. Fields that hold no content are removed without asking.
Output
Synced manifest from ./areca.config.tsQuirks
- Collections missing from the file are turned off. A push turns off any collection in the CMS that the file does not define. Turned-off collections are not deleted, but their entries stop going live until the collection is turned on again.
- The payload is checked before sending. Duplicate field keys and unsafe identifiers fail in the SDK before any request is made.
areca manifest pull
Reads the content definitions from the CMS and writes them into your config file. Use it when someone changed a content type in the CMS and you need to match it in code.
areca manifest pull
areca manifest pull --config ./areca.config.ts --yes| Flag | Type | Default | Description |
|---|---|---|---|
--config <path> | path | ./areca.config.ts | The config file to write. |
--yes, -y | boolean | false | Accept every confirmation: removals, and replacing a config that manifest pull did not write. |
Behavior
- The command fetches the content definitions from the CMS.
- If the config file exists, it loads it. The site key is taken from that file.
- The review lists the changes: collections and site content sections (
+added,~changed,-removed), and site languages (+ language fradded,- language deremoved,~ main language nl -> enfor a new main language). A change to languages alone is listed too. - If the file already matches the CMS, the command writes nothing and prints
areca.config.ts is already up to date. - Additions and changes apply without a question: new collections and fields, changed labels, types or options, and added languages. The review lists them.
- Removals need confirmation. A removal is a collection, a site content section, a field, a language, or a changed main language. The answer defaults to No.
- In a terminal, the command asks, for example,
Remove field subtitle from articles. Continue?. - Without a terminal, the command fails, names what would be removed, and asks you to re-run with
--yes. It writes nothing.
- In a terminal, the command asks, for example,
- The command writes the config file. It does not keep comments or helper code.
The first line of a generated file is // Generated by `areca manifest pull` . That line marks the file as the pull's own. A file without it (hand-written, or from areca init with collections) still asks before a populated config is replaced, even when nothing changed.
A config file that defines no collections is overwritten without a prompt, even if it contains comments or helper code.
Environment variables
| Variable | Required | Use |
|---|---|---|
ARECA_CMS_URL | Yes | CMS base URL. |
ARECA_SITE_TOKEN | Yes | Site token, sent as a bearer token. |
ARECA_SITE_KEY | Only without a config file | The site key, used when the config file is missing or has no siteKey. |
Output
Wrote ./areca.config.ts with 2 collection(s) (+1 ~0 -0)If you decline a prompt, the command prints Aborted and exits with 0. A refusal without a terminal exits with a non-zero code and writes nothing.
Quirks
--configcan point outside the project. The file is written wherever the path points. Loading the existing config also runs it.- Writes follow symlinks. The file is written with no symlink check.
areca sync-manifest
A deprecated alias of areca manifest push. It takes the same optional [config] argument and has the same behavior, environment variables and output. Use manifest push in new scripts. The alias is kept so that existing package.json scripts keep working.
areca run
Runs any other command with the environment loaded from .env.local and .env. Use it to start your dev server with Areca variables present.
areca run -- vite --port 3001The arguments after -- form the command. The -- is required, and at least one argument must follow it. Otherwise the command fails with Missing command. Usage: areca run -- <command>.
Behavior
- The command runs in a shell with inherited input and output. It exits with the child's exit code.
- If the child is stopped by a signal,
areca runexits with1. - If the command cannot start, the error is printed and
areca runexits with1.
Quirks
- Arguments are joined into one string. The words are joined with spaces and passed to the shell. Quoting is lost. An argument that contains a space must be quoted in your shell, and then it is passed through as typed. Keep commands simple, or put complex commands in a
package.jsonscript. - Environment variables stay with the child process. The variables are passed to the command you run. They are not exported to your shell.
Exit codes
| Code | Meaning |
|---|---|
0 | Success. Also used for --help, for an init you cancel at a prompt, and for a manifest pull you decline. |
1 | Any error: a parse error, a failed request, a file error, or a missing value. |
| Child code | areca run -- exits with the exit code of the command it ran. |
Cancelling init exits with 0 and prints Operation cancelled. That is easy to miss in a script. Pass --yes and all three values when you script init.
Environment variables
| Variable | Read by | Description |
|---|---|---|
ARECA_CMS_URL | pull, manifest push, manifest pull | CMS base URL. Trailing slashes are removed. |
ARECA_SITE_TOKEN | pull, manifest push, manifest pull | Site token. Required by every command that talks to the CMS. |
ARECA_SCHEMA_TOKEN | manifest push | Schema token, used only for the push. |
ARECA_SITE_KEY | manifest pull | Site key, used only when the config file is missing or has no siteKey. |
ARECA_SNAPSHOT_ID | pull | The publication to pull, unless --publication is given. Empty or 0 selects the live publication. |
ARECA_CONTENT_DIR | The generated module, at run time | The content folder that content reads. The default is the --out folder that pull used. It is not read by the CLI. |
Areca's deployments also set ARECA_SNAPSHOT_ID as a Docker build argument, which changes on every release and so stops Docker from reusing an older pull. See Go-live builds.
For the CMS's own environment variables, see Configuration.
Related
- Installation walks through
areca init. - Schema sync explains when to run
manifest pushandmanifest pull. - Pulling content explains the output of
areca pull. - Errors and limits lists the messages these commands print.