Node
On Node, Tenon runs inside your site's server process. This page shows how to build and start it, where the data lives, and what to set in production.
Before you start
- Node 24 or newer on the server.
- A project from
npm create tenoncms@latestwith the target Node, or a site set up as in Add to an existing site. - Astro needs the Node adapter,
@astrojs/node, instandalonemode. Nuxt, TanStack Start and Standalone build a Node server by default.
Build and start
Build the site, then start its server:
npm run build
node --env-file-if-exists=.env ./dist/server/entry.mjs
npm run build
node --env-file-if-exists=.env .output/server/index.mjs
npm run build
node --env-file-if-exists=.env .output/server/index.mjs
- The starters add the start command as
npm start. --env-file-if-exists=.envloads.envwhen it exists. Variables set on the host work too.- The server listens on
PORT. In a container, also setHOST=0.0.0.0. - Jobs need no setup. The Nitro task of Nuxt, TanStack Start and Standalone runs every minute. On Astro, a timer starts with the first request. See The clock.
Keep the data
The database and the uploads MUST live on a disk that survives a redeploy. A container's own filesystem goes away with the container, so mount a volume:
| What | Where by default | Set with |
|---|---|---|
| SQLite or libSQL | ./cms.db | DATABASE_URL (file:/var/lib/my-site/cms.db) or DATABASE_PATH |
| PGlite | ./.pglite | DATABASE_DIR |
| Media files | ./.uploads | dir of local() |
Relative paths start at the working directory of the process. Use absolute paths in production, so a start from another folder finds the same data.
import { local } from "tenoncms/media/local";
export default defineCms({
// ...
media: {
storage: local({ dir: "/var/lib/my-site/uploads" }),
},
});
To run more than one server, every server MUST see the same data. Use a database server, like Postgres or Turso, and a bucket, like S3 or R2. A disk on one server does not reach the others. See Databases and Media storage.
Set the environment
The starters use these names:
| Variable | What it is |
|---|---|
TENON_SECRET | Signs sessions. At least 32 characters: openssl rand -hex 32 |
TENON_SITE_URL | The public origin, like https://example.com |
DATABASE_URL | libSQL or Postgres: a file, a Turso URL or a Postgres URL |
DATABASE_AUTH_TOKEN | libSQL: the Turso token. A file needs none |
DATABASE_PATH | sqlite(): the SQLite file |
DATABASE_DIR | PGlite: the folder of the database |
In Nuxt, each variable has the NUXT_ prefix, like NUXT_TENON_SECRET. A bucket, an image service and email add their own variables. The starter lists all of them in .env.example.
Leave TENON_SITE_URL unset in development only. In production, sign-in and every link in an email use it.
Put a reverse proxy in front
Serve the site over HTTPS, for example behind nginx or Caddy. Set TENON_SITE_URL to the https origin the visitor sees, not to the port of the Node server.
With the local disk, every upload part goes through your server, up to 16 MB each. The body limit of the proxy MUST be larger, for example in nginx:
client_max_body_size 20m;
A bucket does not need this. The browser uploads straight to it.
Install on the server's platform
Some packages ship native code for one operating system and CPU: @libsql/client for SQLite and Turso, and sharp for the ipx image provider. Install the dependencies and build on the same platform the server runs on. In a container, run npm ci and the build inside the image. Do not copy node_modules from your machine.
Related resources
- Deployment overview: what every deployment needs, and a checklist.
- Databases: SQLite, Turso, Postgres and PGlite.
- Media storage: the local disk, S3 and R2.
- Backup and restore: back up the database and the uploads.
- The CLI: run
tenonon the server, or against it with--url.