Deployment

Node

Run Tenon on a server or in a container.

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@latest with the target Node, or a site set up as in Add to an existing site.
  • Astro needs the Node adapter, @astrojs/node, in standalone mode. 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
  • The starters add the start command as npm start.
  • --env-file-if-exists=.env loads .env when it exists. Variables set on the host work too.
  • The server listens on PORT. In a container, also set HOST=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:

WhatWhere by defaultSet with
SQLite or libSQL./cms.dbDATABASE_URL (file:/var/lib/my-site/cms.db) or DATABASE_PATH
PGlite./.pgliteDATABASE_DIR
Media files./.uploadsdir 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.

tenon.config.ts
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:

VariableWhat it is
TENON_SECRETSigns sessions. At least 32 characters: openssl rand -hex 32
TENON_SITE_URLThe public origin, like https://example.com
DATABASE_URLlibSQL or Postgres: a file, a Turso URL or a Postgres URL
DATABASE_AUTH_TOKENlibSQL: the Turso token. A file needs none
DATABASE_PATHsqlite(): the SQLite file
DATABASE_DIRPGlite: 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:

nginx.conf
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.