Reference

Configuration

Every option of defineCms(), with its type, its default and the page that explains it.

defineCms() takes one object. Only database and secret are required. Each entry below links to the page that explains the option in depth. For what tenon.config.ts is and how Tenon reads it, see Configuration.

tenon.config.ts
import { defineCms } from "tenoncms";
import { sqlite } from "tenoncms/sqlite";

export default defineCms({
  database: sqlite("./cms.db"),
  secret: process.env.TENON_SECRET!,
  collections: {
    // ...
  },
});

Content

collections

Record<string, Collection>. Default: {}.

The collections, keyed by name. The name media is reserved for the media library. See Collections and globals.

globals

Record<string, Global>. Default: {}.

The globals, keyed by name. While their settings are on, general, seo and translations are taken. See Collections and globals.

blocks

Record<string, Block>. Default: {}.

Shared blocks. A blocks field names them by key instead of defining them. A block MAY name itself, so items nest to any depth.

presets

Preset[]. Default: [].

Ready-made collections, globals and blocks, like pagesPreset(), menuPreset() and stringsPreset() from tenoncms/presets. They merge after your own entries and before the plugins. A duplicate name throws. See Presets.

settings

SettingsOptions | false. Default: general and seo.

The globals on the admin's Settings page. false removes all of them. See Settings.

Site title, tagline and favicon. A Global replaces it, false removes it.Default title, description, image and noindex. A Global replaces it, false removes it.Added with localization when a localized entry has list fields. It holds one switch per entry for keeping the structure of lists the same in every language. false removes it.

Without media, general has no favicon and seo has no image. With localization, both are localized.

localization

LocalizationOptions. Default: off.

Content in several languages. Without it, a localized option throws at startup. See Localization.

The locale codes. MUST NOT be empty or hold duplicates.The locale of a read without locale, and the target of the fallback. MUST be one of locales.A missing value or locale reads as the default locale's. Default: true.How URLs carry the locale. false leaves routing to your app. Default: { prefix: "except-default" }.

populate

PopulateOptions. Default: {}.

Defaults for reads that resolve relations. See Relations.

How many hops populate: true resolves. It also sets the depth of the result types. Default: 2.The deepest population a request over HTTP may ask for. The local API has no limit. Default: 5. depth MUST NOT be larger.

Server

database

DatabaseOptions. Required.

The database. Create it with an adapter:

AdapterImportDatabase
sqlite()tenoncms/sqliteA SQLite file, with node:sqlite
libsql()tenoncms/libsqllibSQL and Turso
postgres()tenoncms/postgresPostgres
pglite()tenoncms/pglitePGlite
durableObject()tenoncms/cloudflareSQLite in a Durable Object

A missing URL or path fails at startup. See Databases.

secret

string. Required.

Signs sessions. It MUST have at least 32 characters, also in development. Read it from an environment variable. See Configuration.

site

SiteOptions. Default: none.

The public origin of your site, like https://example.com. The sitemap, robots.txt and preview URLs use it. It is also the default of auth.baseURL and of the CORS origin. MUST be an http(s) origin without a path. Default: the origin of each request.The name of the site. The admin, the admin bar, emails and passkeys show it. Default: "tenoncms".

See Configuration and Branding.

auth

AuthOptions. Default: {}.

The options of better-auth, passed through. Tenon sets database, secret and basePath (/_tenon/auth) itself, and the models user, session, account and verification MUST NOT set modelName. See Authentication.

Tenon changes these defaults:

KeyDefault in Tenon
baseURLsite.url, then better-auth's environment variables, then localhost in development
appNamesite.name
emailAndPassword.enabledtrue
emailAndPassword.sendResetPassword, emailVerification.sendVerificationEmailThe templates of email, when it is set
rateLimit.storage"database"
user.additionalFieldsAlso has language and timezone
pluginsTenon adds admin(), apiKey(), bearer() and a few of its own, unless you add them

The first user always gets the role admin. At least one sign-in method MUST be on.

roles

Record<string, RoleOptions>. Default: only admin and editor.

More roles for access rules. A name MUST use a-z, 0-9 and -, and MUST NOT be admin or editor.

The name in the admin. Default: the key.Shown where an admin picks a role.

email

EmailOptions. Default: off. Without it, cms.email.send() throws. See Email.

The transport: smtp(), cloudflareEmail() or a custom adapter.The sender of every message, like My Site <hello@example.com>.Replacements for resetPassword, verifyEmail, invite, signInLink, magicLink and emailOtp. See Change the built-in emails.

media

MediaOptions | boolean. Default: local files in .uploads.

The media library, and with it image and file fields. false turns it off. On Cloudflare Workers, or in a read-only folder, the default is off and true throws. See Media.

Where files go: local(), s3(), r2() from tenoncms/media/*, or your own. See Media storage.The largest file, in bytes. Default: 100 * 1024 ** 2 (100 MB).The allowed MIME types. image/* works. Default: all.

Responsive image variants. Default: false. See Responsive images.

KeyTypeDefault
providerImageProvider, required
formatstring"webp"
qualitynumber85
sizesnumber[][320, 640, 1024, 1536, 1920]
presetsRecord<string, Modifiers>{}
maxSizenumber, in bytes50 MB. Bigger images get no variants
The access rules of the library. read also guards the file and image URLs. Default: everyone reads, signed-in users write.beforeUpload, afterUpload, beforeChange, afterChange, beforeMove, afterMove, beforeDelete and afterDelete.

cors

CorsOptions. Default: off.

CORS for pages on another origin, with the options of Hono's cors(). Your keys replace the defaults key by key: origin is site.url, credentials is true, allowMethods is ["GET", "POST"] and allowHeaders is ["content-type"]. It covers the read, preview, localization and admin bar routes. It needs origin or site.url. See Headless.

Site output

sitemap

SitemapOptions | false. Default: on.

Serves /sitemap.xml with the published documents of every collection that has a permalink. entries: ({ cms, entries }) => entries adds, drops or changes entries. false turns it off. See Sitemap and robots.txt.

robots

RobotsOptions | false. Default: on.

Serves /robots.txt. By default it allows / and /_tenon/media/, disallows /_tenon/, and links the sitemap. With the SEO setting noindex, it disallows /. rules: ({ cms, rules }) => rules changes the groups. false turns it off.

Automation

jobs

JobsOptions. Default: none. See Jobs.

Tasks from defineTask(), by name. A name MUST NOT start with tenon:.Cron patterns with five fields, mapped to task names. See Recurring jobs.Opens the clock route for Authorization: Bearer <secret>. Without it, the route does not exist.

webhooks

Record<string, Webhook>. Default: {}.

Outgoing webhooks, by name: url, collections, globals, events, payload, debounce, secret and headers. See Send webhooks.

hooks

RootHooks. Default: {}.

Hooks for every collection and global. They run after the hooks of the entry and of the plugins. See Hooks.

Lifecycle

All four take one function. See Lifecycle hooks.

OptionRuns
seedOnce, on a database without documents and globals
onInitOn every start, after seed, before the first request
afterImportAfter cms.import() commits
afterErrorAfter an unexpected error in a request, a job, seed or onInit

Admin and plugins

admin

AdminOptions | false. Default: the admin at /admin.

false serves no admin, no admin bar and no device login for the CLI. See Admin.

Where the admin opens. Letters, digits, - and _. MUST NOT be / or start with /_tenon. Default: "/admin".The wide logo. Default: the icon and the site name.The square icon of the collapsed sidebar.Default: icon, then the favicon of your site, then Tenon's icon.The label and the menu place of the media library.Inputs for custom:<key> fields. See Custom fields.Pages of your own. See Custom pages and actions.Buttons that run code on the server. Default access: admins. See Actions.The bar on your site for signed-in editors. Default position: "bottom-center". See Admin bar.

richtext

{ extensions?: Record<string, RichtextRegistration> }. Default: {}.

Tiptap extensions for richtext fields, keyed by the name that a field's allowed lists. Each has a schema for the server and a client from clientRef(). See Rich text extensions.

plugins

Plugin[]. Default: [].

Plugins from definePlugin(). They merge in list order, before your own hooks. See Plugins.

KeyWhat it adds
nameRequired. Prefixes the routes and the task names
collections, globalsEntries, like your own
hooks, mediaHooksHooks for every entry, and for the media library
routesRoutes under /_tenon/<name> that need a session
publicRoutesRoutes under /_tenon/<name> without a session
middleware, publicMiddlewareMiddleware for requests with a session, or for all
jobstasks and scheduledTasks. Names start with <name>:
richtext, adminEditor extensions and admin parts
seed, onInit, afterImport, afterErrorLifecycle hooks

Startup checks

defineCms() checks the config when it loads, and throws before the first request.

  • secret, site.url, cors, database and media.storage are checked together. The error tenoncms: invalid config lists every problem among them.
  • Every other check throws on its own problem, like an unknown role in an access rule, a cron pattern without five fields or a webhook URL that is not http(s).