Standalone
A standalone project runs only the CMS: the HTTP API under /_tenon and the admin. It has no pages. Your frontends read the content over HTTP.
When to use it
Use a standalone project when:
- Your frontend is not a Vite app, or is not written in JavaScript.
- Several frontends, like a site and a mobile app, share one CMS.
- The CMS runs on its own host, like
cms.example.com.
If your site runs on Astro, Nuxt or TanStack Start, put Tenon inside it instead. You deploy one app, and drafts and the live preview work without shared cookies. Other apps can still read that CMS over HTTP.
Create a project
Run the wizard and pick Standalone:
npm create tenoncms@latest
pnpm create tenoncms
yarn create tenoncms
bun create tenoncms
Start it with npm run dev and open the URL it prints. / redirects to the admin, where you create the first admin. See create-tenoncms for every question and flag.
The project is a small Vite app with Nitro. Three files make it work:
import html from "#tenon/admin-html";
import cms from "./tenon.config";
const admin = cms.adminPath!;
export default {
fetch(request: Request) {
const { pathname } = new URL(request.url);
if (pathname === "/") return Response.redirect(new URL(admin, request.url), 302);
if (pathname === admin || pathname.startsWith(`${admin}/`)) {
return new Response(html, { headers: { "content-type": "text/html; charset=utf-8" } });
}
return cms.fetch(request);
},
};
server.tsis the server entry. It serves the admin page atadmin.pathand hands every other request to the CMS.tenonAdmin()builds the admin, and Nitro builds the server.tenonAdmin()also runs due jobs every minute. See TanStack Start for its options.cms.adminPathholdsadmin.path.tenonAdmin()throws withadmin: false, so the path is always set.site.urlandauth.baseURLreadTENON_SITE_URLandTENON_CMS_URL. Leave both unset while the CMS runs alone. Set both when a site on another origin reads it.
Read content from another app
Any app reads published content with the client from tenoncms/client:
import { createClient } from "tenoncms/client";
const cms = createClient({ baseUrl: "https://cms.example.com" });
const posts = await cms.find("posts", { limit: 10 });
An app in another language sends plain requests, like GET https://cms.example.com/_tenon/collections/posts?limit=10.
A site on another origin that shows drafts, the admin bar or the live preview needs more: site.url and auth.baseURL in the config, shared cookies and a request client. Headless covers the origins, the cookies, types, media URLs and the limits. Build a headless site with Next.js walks through both sides, step by step.
Deploy
Related resources
- Headless: read from a site on another origin, with drafts and the live preview.
- Build a headless site with Next.js: a site and a standalone CMS, step by step.
- HTTP API and client: the client, its options and the routes.
- API keys: read and write from a service.
- Rebuild on publish: build a static frontend again when content changes.