Overview
Tenon has two command-line tools. create-tenoncms starts a new project. tenon maintains a project: it backs it up, restores it, upgrades it and manages its users. Both need Node 24 or newer.
Commands
| Command | What it does |
|---|---|
npm create tenoncms | Creates a new project from a starter |
tenon backup | Writes all data into a ZIP file |
tenon restore | Replaces all data with a backup |
tenon users | Invites, recovers and manages users |
tenon media regenerate | Renders image variants again |
tenon upgrade | Installs the latest tenoncms |
tenon login, tenon logout | Signs in to a deployed site, and out again |
tenon comes with the tenoncms package, so every project that has tenoncms has it. Run it with your package manager:
npx tenon backup
npx tenoncms backup is the same command. npx tenon --help lists every command and flag.
@tenoncms/cli package. Remove it: tenoncms has the command now.Local or remote
Each command works on the project in the current folder, or on a running site.
On the local project
Without --url, the CLI loads tenon.config.ts and opens the database itself, like your dev server does. It needs no sign-in.
- It reads
.env,.env.local,.env.productionand.env.production.local, like a production build. A variable set in the shell wins. - In Astro, the defaults of
env.schemainastro.config.tsapply. - In Nuxt, it loads
runtimeConfigfromnuxt.config.ts, with theNUXT_variables over it. --config <file>loads another config file.
This works for SQLite, Turso, Postgres and PGlite. A config for Cloudflare runs only on Cloudflare, so use --url there.
.env.production points at the production database, local commands work on production too, restore and users remove included.On a running site
With --url, the CLI talks to a running site over HTTP, local or deployed. Sign in first with tenon login, or pass an API key:
npx tenon login https://example.com
npx tenon backup --url https://example.com
Which command works where
| Command | Local | --url |
|---|---|---|
backup, restore | Yes | Yes |
users create | Yes | Yes |
users recover, list, deactivate, reactivate, remove | Yes | No |
media regenerate | Yes | No |
upgrade | Yes | No |
The local-only commands need the database or the media storage itself. users recover works even when nobody can sign in, for that reason.
Options for every command
backup, restore, users and media share these options. Each command page lists its own.
--url. Default: tenon.config.ts.TENON_URL.tenon login. Default: TENON_API_KEY.Environment variables
| Variable | What it sets |
|---|---|
TENON_URL | The site for --url. With it, local-only commands refuse to run |
TENON_API_KEY | The key for --api-key |
XDG_CONFIG_HOME | Where tenon login stores its sessions. Default: ~/.config |
Run in CI
A script has no browser for tenon login and no terminal for questions:
- Set
TENON_URLinstead of--url. - Create an API key with the Backup permission, and set it as
TENON_API_KEYinstead of--api-key.readbacks up,updaterestores. - Pass
--yesto the commands that ask first:restore,upgrade,users recover,deactivateandremove.
TENON_URL=https://example.com TENON_API_KEY=$BACKUP_KEY npx tenon backup --out backup.zip
A command exits with 0 on success, and with 1 and a message on failure. A cancelled question also exits with 1.
Common errors
| Message | What to do |
|---|---|
Not signed in to <url>. Run tenon login <url>, or pass --api-key. | Run tenon login, or set TENON_API_KEY. |
<config> only runs on Cloudflare. Pass --url … | The config imports cloudflare:*. Use --url with the deployed site. |
<config> has no default export of defineCms() | --config names the wrong file, or the file does not export default defineCms(…). |
Pass --yes to … without questions. | The command asks first, and there is no terminal. Add --yes. |
tenon … works on the local project only. | The command needs the database itself. Unset TENON_URL and run it where the config reaches it. |
tenon needs Node 24 or newer | Update Node. |
Related resources
- tenon login: sign in to a deployed site.
- Backup and restore: what a backup holds, and other ways to make one.
- API keys: access for scripts.