Skip to main content
CMS

Customizing the CMS

Use these cmsPlugin() options to tailor how the CMS looks and works for your team. For the full list, see CMSPluginOptions in the API reference.

Branding and themes

name appears in the CMS header and favicon replaces the browser tab icon. Set minimalBranding: true to swap the Root.js logo for your project name.

Themes (currently experimental) let you restyle the CMS with a stylesheet loaded after the default styles, either from a file relative to the project root or an inline css string:

ts
// @/root.config.ts

cmsPlugin({
  // ...
  themes: [{id: 'brand', name: 'Brand', file: './cms/brand.css'}],
  defaultTheme: 'brand',
}),

Users can choose a theme under Settings → Theme, with defaultTheme used until they pick one. That same page lets admins add project-wide CSS and lets individual users add personal CSS without redeploying.

To write a theme by hand, copy packages/root-cms/ui/styles/theme.css from the Root.js repo and adjust its values. The --cms-* custom properties are kept stable across releases, whereas rules targeting internal CMS class names may break on upgrades.

You can also have a coding agent generate a theme from your brand colors, a logo, or a link to your site. Paste this prompt in your project:

Make a CMS theme that matches our brand. Follow the instructions at
https://rootjs.dev/skills/root-cms-theme.md

The agent asks how you want the theme to look and whether to save it as a shared theme or output CSS for Settings → Theme. It only sets --cms-* properties, verifies text contrast in light and dark mode, and either registers the theme in themes or hands you the CSS. You can also install the skill locally as root-cms-theme with root-cms skill.install.

Access control

Users sign in with Google, and their permissions come from their assigned role (see Security rules and roles). Sign-in is always required for /cms/ routes and any URL with ?preview=true, which the editor uses to preview draft content.

Use isLoginRequired(req) to require sign-in on other parts of your site (like a staging server or internal section), and isUserAuthorized(req, user) to add custom rules for who is allowed to sign in:

ts
// @/root.config.ts

cmsPlugin({
  // ...
  isLoginRequired: (req) => req.path.startsWith('/internal/'),
  isUserAuthorized: (req, user) => user.email.endsWith('@example.com'),
}),

Embedding the editor

@blinkk/root-cms/browser-client lets another site open the CMS editor or Root AI, such as an "Edit this page" button on a staging site. Because framing the CMS is blocked by default, add the embedding site's origin to allowedIframeOrigins:

ts
// @/root.config.ts

cmsPlugin({
  // ...
  allowedIframeOrigins: ['https://staging.example.com'],
}),
ts
// On https://staging.example.com

import {RootCMSBrowserClient} from '@blinkk/root-cms/browser-client';

const cms = new RootCMSBrowserClient({cmsOrigin: 'https://example.com'});

button.addEventListener('click', () => {
  const editor = cms.openEditor('Pages/about', {deeplink: 'hero.title'});
  editor.on('published', () => location.reload());
});

openEditor() opens a pop-up window by default; pass {mode: 'iframe', container} to embed it in the page instead. The returned handle emits ready, saved, published, error, and close events, and autosave is disabled. Call openRootAI({docId}) to open Root AI with a document as context.

Live preview messages

Pages can communicate with the editor while rendered in its preview pane. Using RootCMSBrowserClient.connectPreview(), a page can scroll the editor to a field (for "click to edit"), highlight whichever field is currently focused, and switch the editor to another doc as the user navigates. Enable messaging with preview.channel: true for two-way communication, or 'to-preview' / 'from-preview' for one direction.

ts
// @/root.config.ts

cmsPlugin({
  // ...
  preview: {channel: true},
}),
ts
// In your page's client-side code.

import {RootCMSBrowserClient} from '@blinkk/root-cms/browser-client';

const preview = RootCMSBrowserClient.connectPreview();
if (preview.isEmbedded) {
  // Keep the editor on the doc for the page being previewed.
  preview.navigateToDoc('Pages/about');
  // Outline the element for the field being edited.
  preview.on('highlight', ({deepKey, scroll}) => {
    // ...
  });
  // Click an element to edit its field.
  heroTitle.addEventListener('click', () => preview.focusField('hero.title'));
}

Outside the preview pane, isEmbedded is false and every call is a no-op, so it's safe to include in production bundles. navigateToDoc() asks the editor to confirm before switching docs; pass {confirm: false} to switch immediately.

Image serving

By default, uploaded images are served directly from Cloud Storage. Setting gci: true serves them through a Google image-serving URL instead, which supports on-the-fly resizing and format conversion. By default this uses the hosted service at services.rootjs.dev; pass a URL string to gci to use your own instance. Your storage bucket needs fine-grained access control, and the service account listed at https://services.rootjs.dev/_/service_account needs owner permissions on it.

Search and the dependency graph

Global search indexes every document in the CMS and stays current via the scheduled job. Use searchIndex to narrow what gets indexed with includeCollections, excludeCollections, includeDocIds, and excludeDocIds (doc IDs use the Pages/about format).

The dependency graph tracks references between documents via schema.reference() and schema.references() fields. It's enabled by default and also updated by the scheduled job. You can use it to load everything a page depends on in a single batch request:

ts
const depIds = await cmsClient.getDocDependencies(['Pages/index'], {
  mode: 'published',
});
const req = cmsClient.createBatchRequest({mode: 'published'});
req.addDoc('Pages/index');
depIds.forEach((docId) => req.addDoc(docId));
const res = await req.fetch();

Dependencies are resolved transitively unless you pass transitive: false. Set dependencyGraph: false to disable the graph, or pass {includeCollections, excludeCollections} to limit which collections are scanned.

Other options

  • defaultOneOfVariant: sets the default UI for oneOf fields to 'dropdown' (the default) or 'picker'. Individual fields can still override this with their own variant.

  • logLevel: controls CMS console verbosity, from 'debug' to 'silent'. Defaults to 'info'.

  • watch: set to false to stop the dev server from watching schema files and regenerating root-cms.d.ts.

  • firebaseConfig.databaseId: targets a named Firestore database instead of the default one.

1
2
3
4
5
6
7
8
9
10
11
12
Breakpoint: