Admin extensibility
Four tiers of customization for the React admin UI.
The admin UI is designed around composition, not overrides. Customizations inject into a working system — you never rebuild a component from scratch to change one thing.
Tier 1 — Config values
Simple branding and entity display. No React knowledge needed for branding; summary callbacks are optional.
export default config({
admin: {
logo: "/logo.svg",
title: "My CMS",
},
// ...
});
logo sets the sidebar logo image. title sets the browser tab title.
Entity summary
Control how documents appear in list views and relation pickers by defining a summary on the entity’s admin option. The fields array declares which fields to fetch — the admin only loads these for list views instead of the full document.
const authors = entity("authors", {
admin: {
summary: {
fields: ["name", "bio", "avatar"],
title: ({ data }) => data.name,
description: ({ data }) => data.bio,
media: ({ data }) => data.avatar
? <img src={`/api/assets/${data.avatar.id}`} alt="" />
: <UserIcon />,
},
},
fields: [/* ... */],
});
The data argument in callbacks is typed to only the fields you listed — data.name autocompletes, data.somethingElse is a type error. When summary is omitted, all fields are fetched for list views.
See the Config Reference — admin.summary for the full API.
Entity list columns
Control which columns appear in the entity list view — and in what order — using admin.list. When list is omitted the admin renders a default layout based on admin.summary.
const posts = entity("posts", {
admin: {
list: {
fields: ["title", "status"],
defaultSort: { field: "createdAt", order: "desc" },
columns: [
{
label: "Title",
sortKey: "title",
render: ({ data }) => data.title,
},
{
label: "Status",
render: ({ data }) => data.status,
},
"createdAt",
],
},
},
fields: [/* ... */],
});
fields— same assummary.fields: limits what the API fetches for the list view.columns— ordered array of column definitions or built-in strings ("createdAt","updatedAt","locales"). Each custom column can optionally declare asortKeyto enable server-side sorting for that column.sortKeyis type-safe and constrained to scalar fields and dotted paths.defaultSort— sort applied on first load when the URL carries no sort param. Thefieldvalue must match a validsortKeyor one of the built-in sortable columns. Clicking a column header in the UI overrides it for that session.
See the Config Reference — admin.list for the full API.
Bulk actions
Add actions that operate on multiple selected documents at once. Bulk actions appear in a bar at the bottom of the list view whenever one or more documents are selected.
When an entity has versions: true, Publish and Unpublish are injected automatically — no bulkActions config needed. Use bulkActions for custom editorial operations beyond those built-ins.
import { StarIcon } from "@phosphor-icons/react";
const posts = entity("posts", {
admin: {
bulkActions: [
{
label: "Feature",
icon: StarIcon,
iconOnly: true,
callback: ({ set }) => {
set({ featured: true });
return {
success: (n) => `${n} ${n === 1 ? "post" : "posts"} featured`,
error: "Failed to feature posts",
};
},
},
],
},
fields: [/* ... */],
});
Callback context
The callback receives a context object with two mutually exclusive helpers — use one per action:
| Helper | Description |
|---|---|
set(data) |
Applies a static partial update to all selected documents. |
map(fields, fn) |
Fetches the listed fields for all selected documents, then calls fn per document to produce a per-document update. Use when the new value depends on the current document state. |
set is synchronous. map is async — await it before returning messages.
// map example — append a tag without overwriting existing ones
{
label: "Mark as featured",
callback: async ({ map }) => {
await map(["tags"], (doc) => ({
tags: [...(doc.tags ?? []), "featured"],
}));
return {
success: (n) => `${n} ${n === 1 ? "post" : "posts"} marked as featured`,
partialSuccess: (succeeded, failed) => `${succeeded} marked as featured, ${failed} failed`,
error: "Failed to mark posts as featured",
};
},
}
set can’t do this — it would replace the entire tags array. map fetches the current value per document first, so you can safely append.
Toast messages
The value returned from callback controls the toast shown after the action completes. All keys are optional — omitting one falls back to a generic message.
| Key | Type | Description |
|---|---|---|
success |
(count: number) => string |
Shown when all selected documents updated successfully. |
partialSuccess |
(succeeded: number, failed: number) => string |
Shown when some documents succeeded and some failed. |
error |
string |
Shown when all documents failed. |
Confirm modal
Set confirmModal to require an explicit confirmation step before the action runs. The modal is shown after the user clicks the action button.
confirmModal: {
title: "Delete drafts?",
description: "This cannot be undone.",
actions: {
confirm: "Delete", // confirm button label (default: "Confirm")
cancel: "Keep", // cancel button label (default: "Cancel")
},
}
See the Config Reference — admin.bulkActions for the full API.
Tier 2 — Injection slots
Add to the UI without replacing anything. Navigation, auth, and routing all keep working.
Pages
admin.routes adds full pages to the admin. Each renders inside the admin shell, next to the
sidebar, at /admin/custom/<path>, and gets a sidebar item:
import { config } from "@cms/config";
import { ChartBarIcon } from "@phosphor-icons/react";
export default config({
admin: {
routes: [
{
path: "reports",
label: "Reports",
icon: ChartBarIcon,
roles: ["editor"],
component: () => import("./admin/reports"),
},
],
},
// ...
});
// admin/reports.tsx
export default function Reports() {
return <h1>Reports</h1>;
}
-
pathis one or more lowercase segments (reports,reports/monthly), with no leading or trailing slash. Paths must be unique. -
componentmust be a() => import()of a module with a default export. The page’s code loads only when it’s opened, andcms.confignever loads it in Node. -
rolesworks as it does for server routes: admins can always open the page, other roles only when listed. Anyone else gets a “not found” page, and the sidebar hides the item. Guard the data the page reads with the API’s own permissions, or a server route’sroles, since the check in the admin only hides the page. -
Pages are ordinary React components: use
@cms/uiand the hooks from Tier 4.@cms/admin/pageexportsPageLayout, the layout the built-in pages use (title, description, width), the APIclient, signed in as the editor, and the admin router’sLinkanduseSearch, so a page links to a document (to="/entity/$name/$id") or another page without a full reload and reads its own?query. It’s safe to import from a package, which the main@cms/adminentry isn’t:import { PageLayout as Layout } from "@cms/admin/page"; export default function Reports() { return ( <Layout> <Layout.Container> <Layout.Header> <Layout.Title>Reports</Layout.Title> <Layout.Description>Monthly numbers.</Layout.Description> </Layout.Header> </Layout.Container> </Layout> ); } -
To edit fields with no document behind them (settings, an import form, a preview), use
DetachedFormfrom@cms/admin/fields. It renders the standard inputs, relation, asset, slug and package inputs included, over a value your page holds. Nothing is validated or saved, andlocaleis what relation pickers filter by:import { DetachedForm } from "@cms/admin/fields"; import { relation, text } from "@cms/config"; import { useState } from "react"; const fields = [text("title"), relation("author", { to: "authors" })]; export default function Settings() { const [value, setValue] = useState<Record<string, unknown>>({}); return ( <DetachedForm fields={fields} value={value} onChange={setValue} locale="en"> <DetachedForm.Fields /> </DetachedForm> ); }usePreviewData({ schema, value, initialValue }), from the same entry, gives a preview what live preview gets: the last valueschemaaccepted, with every{ id, _entity }relation swapped for its record.
Plugins add pages the same way; see Plugins → Admin pages and sidebar.
Sidebar
When you provide a sidebar function, you take full control of the navigation structure. The function receives builder helpers and returns an array of sidebar elements:
import { config } from "@cms/config";
import { BookOpenIcon, GearIcon } from "@phosphor-icons/react";
export default config({
admin: {
sidebar: ({ group, item, page, plugins, divider, builtins }) => [
builtins.DASHBOARD,
group("Content", {
collapsible: true,
children: [
item("posts", { label: "Posts", icon: BookOpenIcon }),
item("authors", { label: "Authors" }),
],
}),
divider(),
item("settings", { label: "Settings", icon: GearIcon }),
page("reports"),
...plugins(),
divider(),
builtins.ASSETS,
],
},
// ...
});
Builders
| Builder | Description |
|---|---|
item(name, options?) |
A link to an entity or global. The name is auto-resolved — entities and globals share a unique namespace. Options: label, icon. |
group(label, options) |
A labeled section. Options: icon, collapsible, defaultOpen, indent, children. Children can be any sidebar element, including nested groups. |
page(path, options?) |
A link to one of your pages, or to a plugin instance’s page with plugin: "<instance name>". Options: label, icon, defaulting to the page’s own. |
plugin(name) |
A plugin instance’s group: its pages, then its entities. |
plugins({ except? }) |
One group per plugin that has pages or entities, in the order they’re registered. Spread it: ...plugins(). |
divider() |
A horizontal separator. |
builtins.DASHBOARD |
The built-in dashboard item. |
builtins.ASSETS |
The built-in assets manager item. |
itemauto-resolves names: if the name matches a global it links to/global/{name}, otherwise to/entity/{name}.- When no
labelis provided, the entity/global title is used. iconaccepts any React component (Phosphor icons recommended).page,pluginandplugins({ except })throw on a path or plugin name that doesn’t exist, andpluginthrows for a plugin with no pages or entities.- When
sidebaris omitted, the default sidebar is used: Dashboard, your pages, your entities, your globals, a Plugins group with one element per plugin, then Assets. - Entities, globals and pages not included in the sidebar are hidden from navigation. Plugin items
are the exception that gets a warning:
cms devlists every plugin page and entity your sidebar leaves out. - Items are filtered by role: an entity is shown when the role can read it, a page when the role can open it, and a group when anything inside it is left. Admin roles see everything the function returns; for other roles, this filter runs after it, whatever it returns.
Per user
The function’s second argument is the signed-in user ({ id, email, name, role }), so the
sidebar can differ by user or role. The admin calls it for each user. Here only Significa staff
see an internal entity:
admin: {
sidebar: ({ group, item, builtins }, { user }) => [
builtins.DASHBOARD,
group("Orders", {
children: [
item("order"),
...(user.email.endsWith("@significa.co") ? [item("order_experience_item")] : []),
],
}),
],
},
This is layout, not access control: an item left out of one user’s sidebar can still be opened by URL and through the API. Set access with role permissions. A sidebar that takes only the builders keeps working.
Dashboard
Replace the default dashboard with a custom React component:
import { config } from "@cms/config";
import { MyDashboard } from "./my-dashboard";
export default config({
admin: {
dashboard: MyDashboard,
},
// ...
});
When provided, the custom component replaces the built-in dashboard entirely. It receives no props — use the CMS hooks (Tier 4) to fetch data.
Dashboard widgets
admin.dashboardWidgets adds cards to the built-in dashboard, above the recent activity. A card is
a component with no props; roles lists who sees it beyond admins (default: admins only):
admin: {
dashboardWidgets: [{ roles: ["editor"], component: () => import("./open-orders") }],
},
Only the project adds widgets: a plugin shows its status on its own page, not on the dashboard. A
custom dashboard replaces the built-in one, widgets included.
Delete actions
admin.deleteActions adds controls to every document’s delete dialog that do something once the
delete commits, like leaving a redirect behind. Each component gets the entity, the document being
deleted, the replacement the editor picked (or null), and onAfterDelete, which takes the work to
run after the delete, or null to withdraw it:
// archive-on-delete.tsx
import { client } from "@cms/admin/page";
import type { DeleteActionProps } from "@cms/config";
import { Checkbox } from "@cms/ui";
import { useEffect, useState } from "react";
export default function ArchiveOnDelete({ entity, document, onAfterDelete }: DeleteActionProps) {
const [enabled, setEnabled] = useState(false);
useEffect(() => {
onAfterDelete(
enabled
? () => client.request("/custom/archive", { method: "POST", body: { entity: entity.name, document } })
: null,
);
}, [enabled, entity, document, onAfterDelete]);
if (entity.name !== "pages") return null;
return (
<label>
<Checkbox checked={enabled} onChange={(event) => setEnabled(event.target.checked)} /> Archive a copy
</label>
);
}
admin: {
deleteActions: [{ component: () => import("./archive-on-delete") }],
},
The work runs after the delete, never inside its transaction: if it throws, the document stays
deleted and the editor sees the error’s message. A component renders null for documents it
doesn’t apply to. onAfterDelete keeps its identity, so it is safe in an effect’s dependencies.
Plugins add theirs with the same key, after the project’s.
Document banners
admin.documentBanners adds notices to the top of every document’s editor, above its fields, in
collections and globals. Each component gets the entity and the document as the editor opened it
(the editorial view, a pending draft merged in), and renders null when it doesn’t apply:
// missing-seo.tsx
import type { DocumentBannerProps } from "@cms/config";
export default function MissingSeo({ entity, document }: DocumentBannerProps) {
if (entity.name !== "pages" || document.metadata) return null;
return <p role="status">This page has no SEO title yet.</p>;
}
admin: {
documentBanners: [{ component: () => import("./missing-seo") }],
},
roles lists who sees a banner beyond admins (default: admins only). Plugins add theirs with the
same key, after the project’s; @cms/shopify warns about deleted or archived items this way.
Tier 3 — Field component overrides
Replace a specific, scoped piece of a field — not the whole page. The form, validation, saving, and permissions are still handled by the framework.
Field-level overrides are defined per-field via admin.components. Each field has four overridable slots: root, label, input, and error. Every custom component receives a Default prop — the built-in component for that slot — so you can wrap, extend, or fully replace any part of a field’s rendering.
import type { InputSlotProps } from "@cms/config";
text("color", {
admin: {
components: {
input: ({ Default, ...props }: InputSlotProps) => <ColorPicker {...props} />,
},
},
});
Slot props
Each slot receives typed props:
| Slot | Key props | Purpose |
|---|---|---|
root |
Default, field, children |
Wraps the entire field (label + input + error) |
label |
Default, field, htmlFor |
The field label |
input |
Default, field, value, onChange |
The input control |
error |
Default, error, id |
The validation error message |
value and onChange are typed as unknown — cast to the expected type at the point of use (e.g., value as string for a text field).
Wrapping vs replacing
To wrap the default, render <Default> and add your customizations around it:
input: ({ Default, value, ...props }) => (
<div>
<Default value={value} {...props} />
<span>{(value as string)?.length ?? 0} / 100</span>
</div>
)
To replace the default, ignore Default and render your own JSX:
input: ({ value, onChange }) => (
<input
type="color"
value={value as string}
onChange={(e) => onChange(e.target.value)}
/>
)
See Fields — Custom field components for the full slot reference and custom field patterns.
Tier 4 — Hooks as public API
The same hooks the built-in UI uses are exported from @cms/admin:
import { useDocuments, useDocument, useMe } from "@cms/admin";
function RevenueWidget() {
const { data } = useDocuments("orders", {
filter: { status: "paid" },
limit: 100,
});
return <div>Revenue: {sum(data)}</div>;
}
Available hooks
| Hook | Description |
|---|---|
useConfig() |
CMS config — entities, globals, locales |
useMe() |
Current authenticated user |
useDocument(entity, id, params?) |
Single document fetch. Return type narrows automatically for known entities (e.g. "_image" returns ImageAsset). |
useDocuments(entity, params?) |
Document list with filtering, sorting, and pagination |
useGlobalDocument(name, params?) |
Single global document fetch |
useEntityDef(name) |
Entity definition and field metadata |
useGlobalDef(name) |
Global definition and field metadata |
useAssets(types, params?) |
Fetch assets by type ("_image", "_video", "_file") |
Query options
The underlying query option factories are also exported, for use with useSuspenseQuery, route loaders, or queryClient.fetchQuery:
import { getDocumentQueryOptions } from "@cms/admin";
import { useSuspenseQuery } from "@tanstack/react-query";
function Post({ id }: { id: string }) {
const { data } = useSuspenseQuery(getDocumentQueryOptions("posts", id));
return <h1>{data.title}</h1>;
}
| Query option | Description |
|---|---|
getDocumentQueryOptions(entity, id, params?) |
Single document query options |
getDocumentsQueryOptions(entity, params?) |
Document list query options |
getSummaryDocumentsQueryOptions(entity, params?) |
Document list with only summary fields — used by list views and relation pickers |
getGlobalDocumentQueryOptions(name, params?) |
Global document query options |
Client
The API client instance is exported for imperative use outside React (event handlers, scripts, data migrations):
import { client } from "@cms/admin";
const { data } = await client.entities.list("posts", { limit: 10 });
Custom components built with these primitives are first-class citizens — they use the same data fetching, caching, and auth as the built-in UI.
Styling custom components
Pages, widgets and field components you write are compiled into the admin, with the admin’s Tailwind
theme from @cms/ui, not your website’s. The admin scans the directory holding cms.config.ts for
class names, but resolves them against its own tokens: bg-background, bg-background-secondary,
text-foreground, text-foreground-secondary, bg-accent, border-border, text-negative, and
Tailwind’s defaults. A class that only your website’s theme defines, such as bg-brand-500 or a
custom font, compiles to nothing in the admin.
Build custom components from @cms/ui and those tokens, so they match the admin and follow its
light and dark modes. Share logic with the website, not styled components.
Design principle
Each tier is additive:
- Tier 1: change values
- Tier 2: inject into existing structure
- Tier 3: swap a specific leaf component
- Tier 4: build anything with the same primitives
You never have to rebuild the sidebar from scratch. You either compose it from builders (Tier 2) or swap a single component while keeping all the data/auth/routing plumbing (Tier 3 + Tier 4 hooks).
Previous
Internationalization
Next
Live preview