Skip to content
Auto
English

CMS

@tapedb/cms is a content management system that runs inside your TapeDB Worker, in your own Cloudflare account. Content lives in your Durable Objects and R2 buckets; editors work in a studio served by the same Worker, or at /studio on your own site; websites read published content from cached, anonymous routes.

The studio's home: counts per content type, a document waiting for review, the latest publishes, and who is in the studio right now.
The studio’s home: counts per content type, a document waiting for review, the latest publishes, and who is in the studio right now.
  • Content types in code. defineContent describes your types and fields in TypeScript; each type becomes TapeDB models with migrations you review and commit.
  • Drafts, revisions, review. Editors work on a draft beside the published document. Publishing writes the next revision; every publish and unpublish leaves an immutable snapshot you can restore.
  • Releases and scheduling. Group documents and publish them together in one transaction, now or at a set time, from the Worker’s cron.
  • Co-editing. Rich text is either locked to one editor at a time or merged live as several people type.
  • A studio. Home, lists, forms, review with word-level change marks, live preview, a media library with focal points, preview links for people without an account, and member management. Every control is the studio’s own and works from the keyboard.
  • Your brand, your inputs. Name, logo, colours, fonts and radii; your own field inputs, previews and home panels in tapedb.cms.tsx.
  • Delivery. Published documents and images on anonymous routes, cached, with a typed SDK for any website and React components for rich text and images.
  • An importer. Records from any system, checked whole before anything is written, re-runnable.

Everything the studio does, a script or another client can do too, and the same rules apply: TapeDB checks each write inside its transaction. Roles decide who drafts, publishes, schedules and deletes; a published document must be complete and valid; a publish based on an older revision is refused; a strong reference cannot be left dangling; a slug is unique among published documents of its type. The studio hides what a role cannot do, but the server is what refuses it.

Role Can
user read published documents
member (contributor) write drafts and release versions, upload images, make preview links
editor publish, unpublish, publish and schedule releases, manage all media
admin delete documents
owner manage members (with TapeDB sign-in)

In a project made by tapedb init (TapeDB 0.5 or later):

Terminal window
npx @tapedb/cli add @tapedb/cms
npx @tapedb/cli migrate dev --name cms
npx @tapedb/cli dev

Then open http://localhost:8787/cms. tapedb init --cms does the same for a new project.

add installs the package, lists it under "tapedb": { "extensions": [...] } in package.json and sets the project up:

  • cms.content.ts with a first content type, post;
  • content among the schema’s extensions and cms({ content }) among the Worker’s, with their imports;
  • the CONTENT R2 bucket, the IMAGES binding and a one-minute cron trigger in wrangler.jsonc, which tapedb deploy creates;
  • tapedb/cms-studio.gen.ts in .gitignore.

A second run changes nothing. Code the CLI cannot edit with certainty, such as options built in another file, it leaves alone and tells you what to add. By hand, the whole set-up is two lines:

tapedb.schema.ts
import { content } from "./cms.content";
export default schema({ /* your models */ }, { extensions: [content] });
// worker.ts
import { cms } from "@tapedb/cms/worker";
import { content } from "./cms.content";
const tapedb = defineTapeDB({ schema, migrations, extensions: [cms({ content })] });

The CMS’s models sit beside your app’s, and its file rules cover public/ only; your own models and rules are unchanged. TapeDB serves the CMS’s routes, hands it every content change after the commit, and runs it on the Worker’s cron. There is no webhook, secret or public URL to configure. See Extensions for how that works.

Terminal window
npx @tapedb/cli deploy

deploy creates the CONTENT bucket if it is missing, builds the studio extension if there is one, and deploys the Worker with its cron trigger. The studio is at https://<worker>.workers.dev/cms; sign-in follows Sign-in.