Skip to content
Auto
English

Branding, sign-in and extensions

Everything on this page is an option of cms() in your Worker:

cms({
content,
studio: {
path: "/cms", // where the studio is served
brand: { … }, // name, logo, colours, fonts, radii
signIn: "auto", // how people sign in
extension: studioExtension, // your inputs, previews and panels
},
});

Without a brand, the studio wears tapedb’s identity: the cassette mark and wordmark, tapedb orange, Space Grotesk, Inter and JetBrains Mono. With one, it carries yours, on every page including sign-in and preview links:

cms({
content,
studio: {
brand: {
name: "Northwind Newsroom",
logo: "<svg viewBox='0 0 32 32'>…</svg>",
accent: { light: "#0f6b73", dark: "#5cc4c9" },
palette: { light: { ground: "#f7f4ee", card: "#fffdf9" } },
fonts: { display: "'Fraunces', serif", reading: "'Source Serif 4', serif" },
css: "@font-face { font-family: 'Fraunces'; src: url(/fonts/fraunces.woff2) }",
radius: { control: 8, panel: 12 },
},
},
});
The same studio under a sample brand: its own name and mark, a teal accent, and an extra Content health panel on the home page.
The same studio under a sample brand: its own name and mark, a teal accent, and an extra Content health panel on the home page.
Option Sets
name the name in the sidebar, on the sign-in page and in the browser tab
logo SVG markup, a same-origin path (/logo.svg), a data:image URL or an https URL
favicon the same forms; defaults to the logo
accent primary actions, focus and change marks: one colour, or { light, dark }
palette any colour token, per scheme: ground, surface, card, raised, line, lineStrong, text, text2, text3, accent, accentSoft, onAccent, ok, danger
fonts font-family lists for display (headings), ui, reading (rich text and preview) and mono
css a stylesheet added after the studio’s; https origins in its url()s are allowed by the page’s content security policy
radius control and panel, in pixels
scheme "system" (default), "light" or "dark"
poweredBy a small “Built on tapedb” line under the sidebar; false removes it

Colours, font lists and assets are checked when the Worker starts. A value the page cannot use throws there, not in an editor’s browser.

studio also takes a list. Each studio serves the same content at its own path with its own brand, sign-in and extension: one for a newsroom, one for a marketing team, the default for developers.

cms({
content,
studio: [
{}, // /cms, in tapedb's identity
{ path: "/newsroom", brand: newsroom, extension: studioExtension },
],
});

studio: false serves no studio, for a Worker that only delivers content.

studio.signIn decides how people get into the studio:

Value People sign in
"tapedb" with TapeDB’s built-in auth. A signed-out visit goes to /auth?returnTo=/cms (TapeDB’s page, or your own tapedb.auth.tsx) and comes back. The studio lists the person’s workspaces, offers to create one when they have none, and takes each claim with the person’s workspace role.
{ tokenPath } through your app’s own route: GET <tokenPath>?workspace=<id> answers { token, sub, role, name?, workspace? } for the signed-in person. Use this with your own identity system.
"development" with a name and a role, through TapeDB’s development claim route, which answers only outside production
"auto" (default) "tapedb" when the Worker serves TapeDB’s auth routes, otherwise "development"
Signing in to the studio with TapeDB's built-in auth page.
Signing in to the studio with TapeDB’s built-in auth page.

With built-in auth, the CMS needs nothing else:

const tapedb = defineTapeDB({
schema, migrations, auth, authPage,
extensions: [cms({ content, studio: { signIn: "tapedb" } })],
});

Roles come from the workspace membership: owners manage people on the studio’s People page.

Your app adds its own field inputs, document previews and home-page panels in tapedb.cms.tsx, next to tapedb.auth.tsx:

tapedb.cms.tsx
import { defineStudio, type FieldInputProps, type PreviewProps, RichText, useLiveQuery, useStudio } from "@tapedb/cms/studio";
import "./tapedb.cms.css";
const SWATCHES = ["#0f6b73", "#b8440a", "#5b3fa6"];
function Colour({ value, onChange, editable }: FieldInputProps<string>) {
return (
<div className="swatches">
{SWATCHES.map((c) => (
<button key={c} type="button" aria-pressed={value === c} disabled={!editable}
style={{ background: c }} onClick={() => onChange(c)} />
))}
</div>
);
}
function Article({ row }: PreviewProps) {
return (
<article className="article">
<h1>{row.title}</h1>
<RichText doc={row.body} />
</article>
);
}
function Health() {
const { db } = useStudio();
const posts = useLiveQuery(() => db.post.findMany({ where: { publishedAt: { isNull: false } } }), "published-posts", []);
const missing = (posts ?? []).filter((p) => !p.cover).length;
return <p>{missing ? `${missing} published posts have no cover.` : "Every published post has a cover."}</p>;
}
export default defineStudio({
inputs: { colour: Colour }, // fields with { input: "colour" }
previews: { post: Article }, // replaces the generic preview for posts
panels: [{ title: "Content health", component: Health }],
});
An extension's article preview beside the form: the site's own typography, section label and drop cap.
An extension’s article preview beside the form: the site’s own typography, section label and drop cap.

tapedb dev builds the file to tapedb/cms-studio.gen.ts before it starts and again whenever it or anything it imports changes. tapedb deploy builds it before deploying, and npx @tapedb/cli build builds it on its own, for a typecheck or a plain wrangler command. The build needs esbuild (npm i -D esbuild). Pass the result to the studio:

import { studioExtension } from "./tapedb/cms-studio.gen";
cms({ content, studio: { extension: studioExtension } });

A field uses, in order: the input named by its input option, an input registered as "<type>.<field>", an input registered for its kind ("string", "image", …), and otherwise the studio’s own. An input receives:

Prop
value the field’s current value in the draft, or the published document when there is no draft
onChange(next, { now }) saves through the studio’s autosave: after a pause in typing, or at once with now: true
editable false when the document is not open for editing or the person may not edit
field, name, type the field’s definition, its name, and the content type
documentId, row the document and its whole draft
A custom colour input among the studio's own fields, marked changed like any other.
A custom colour input among the studio’s own fields, marked changed like any other.

A preview receives type, row (the draft or the published revision), which ("draft" or "published") and published. It is also what a preview link shows. A panel is any component, shown on the home page under its title.

@tapedb/cms/studio exports what extensions build with:

  • useStudio(): the TapeDB client (db), the content operations (cms), the content types, the signed-in person (sub, name, role), nameOf(id) and go(route);
  • useLiveQuery(() => query, key, fallback): a live TapeDB query as React state;
  • FileImage, RichText, Avatar, MediaPicker;
  • labelOf, excerptOf, textOf.

The extension is its own small script. React, React DOM and @tapedb/cms/studio are the studio’s own copies, shared at run time, so the build stays small and your components are ordinary components inside the studio. CSS the file imports is served with it.