CLI

Overview

The commands, how they reach a project, and the options they share.

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

CommandWhat it does
npm create tenoncmsCreates a new project from a starter
tenon backupWrites all data into a ZIP file
tenon restoreReplaces all data with a backup
tenon usersInvites, recovers and manages users
tenon media regenerateRenders image variants again
tenon upgradeInstalls the latest tenoncms
tenon login, tenon logoutSigns 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.

Older projects MAY still have the @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.production and .env.production.local, like a production build. A variable set in the shell wins.
  • In Astro, the defaults of env.schema in astro.config.ts apply.
  • In Nuxt, it loads runtimeConfig from nuxt.config.ts, with the NUXT_ 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.

If .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

CommandLocal--url
backup, restoreYesYes
users createYesYes
users recover, list, deactivate, reactivate, removeYesNo
media regenerateYesNo
upgradeYesNo

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.

The config to load without --url. Default: tenon.config.ts.A running site instead of the local project. Default: TENON_URL.An API key instead of the session of tenon login. Default: TENON_API_KEY.Asks nothing and takes the defaults. A command that asks before it changes data needs it without a terminal.Lists every command and option.

Environment variables

VariableWhat it sets
TENON_URLThe site for --url. With it, local-only commands refuse to run
TENON_API_KEYThe key for --api-key
XDG_CONFIG_HOMEWhere 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_URL instead of --url.
  • Create an API key with the Backup permission, and set it as TENON_API_KEY instead of --api-key. read backs up, update restores.
  • Pass --yes to the commands that ask first: restore, upgrade, users recover, deactivate and remove.
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

MessageWhat 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 newerUpdate Node.