Skip to content
TanStackPublic

About

Content Management System

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

223 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TanStack CMS

An agent-native, schema-as-code CMS built on TanStack Start and TanStack DB. Developers define content in TypeScript; editors get a full admin UI; app components read and write content as live TanStack DB collections; and AI agents (an in-app content agent, external MCP clients, and in-page WebMCP tools) work on the same content through the same operations, with every agent write going through a human review queue.

# in a TanStack Start app
pnpm add @tanstack/cms-core @tanstack/cms-ui-react
pnpm add -D @tanstack/cms-cli
pnpm exec tanstack-cms init

Read the docs at tanstack.com/cms, starting with the quick start.

The admin UI

The admin ships in @tanstack/cms-ui-react and mounts into your app with createRoutes(definition). It is driven entirely by your schema: a dashboard, a content list across every collection, the block editor, a media library, the review queue, and a profile screen.

The CMS dashboard: per-collection counts, the review queue, and recent activity

Content list across every collection with search, status filters, and per-collection create
Content — every collection, with search, status filters, and bulk actions.
Review queue listing pending agent changes above a chronological audit trail
Review queue — every agent and unprivileged write waits here, above a full audit trail.

The block editor keeps the editorial workflow in the sidebar: revisions and restore, scheduled publish and unpublish, assignment, inline comments, and SEO.

The block editor with the revisions, scheduling, assignment, comments, and SEO panels in the sidebar

TanStack Base

Base is the Dockerized application distribution: a seeded coffee shop with database auth, guided onboarding, and reviewable trends reports. Run docker compose up --build from app/base. Library demonstrations live in examples/.

Built on TanStack Start and TanStack DB

TanStack CMS isn't a separate service in front of your app. It runs inside your TanStack Start app, and your UI reads its content through TanStack DB.

  • TanStack Start is the runtime. The admin, the public pages, and every API endpoint are Start routes shipped in a package and mounted with createRoutes(definition). Each CMS operation is a Start server function (@tanstack/cms-api/start), so the admin and your own loaders call the engine in-process, with no HTTP hop. The same operations are served over HTTP, MCP, and WebMCP for everything outside the app.
  • TanStack DB is the data layer. createCmsCollectionOptions() from @tanstack/cms-client/db turns any CMS collection into a live TanStack DB collection. Components query it with useLiveQuery, join it with data from other services, and mutate it optimistically. Every write still runs through the CMS operations, so validation, revisions, access rules, and the review queue apply. Markdown files can be loaded as content via loadMarkdownDir() from @tanstack/cms-api/markdown.
flowchart LR
  admin["Admin UI and app loaders"] -- "@tanstack/cms-api/start" --> ops
  components["Components<br/>useLiveQuery"] -- "createCmsCollectionOptions()" --> http["/api/cms/v1"] --> ops
  agents["MCP, WebMCP,<br/>content agent"] --> ops
  ops["CMS operations<br/>@tanstack/cms-api"] --> core["@tanstack/cms-core<br/>validation, access,<br/>revisions, review queue"]
  core --> storage[("Storage and media adapters")]
Loading

See the architecture overview for diagrams of data loading, storage, mutations, and agent review.

// A CMS collection as a TanStack DB collection
const products = createCollection(
  createCmsCollectionOptions<Product>(cms, queryClient, 'product'),
)

// In a component: a live query, and an optimistic write that runs save
const { data } = useLiveQuery({
  query: (q) => q.from({ p: products }).where(({ p }) => gt(p.stock, 0)),
})
products.update('acme-anvil', (d) => {
  d.stock -= 1
})

The built-in admin calls the Start server functions directly; TanStack DB is for your app's own routes and components. See Data Layer with TanStack DB.

Features

  • Schema as code, typed end to end. One defineCms config drives the validation schema, admin forms, block editor, public renderer, agent tool schemas, the HTTP API, and the typed client. Field types include text, markdown, richtext, relations, blocks, group, array, slug, select, dates, json, and more, with validation (functions or Standard Schema), unique and indexed fields, and async hooks.
  • Publishing workflow. Drafts of published documents, revisions with restore, scheduled publish and unpublish, optimistic concurrency, referential integrity, bulk actions, and a review queue for authors and agents.
  • Secure by default. No implicit admin in production. Built-in viewer, author, editor, and admin roles plus custom roles, per-collection and per-field access, scoped API keys, CSRF checks, rate limits, upload limits, and SVG sanitization. Bring any identity provider through auth.getUser.
  • Pluggable storage and media. Postgres is the storage engine: embedded (PGlite) for development with no server, and a Postgres server for production, both via @tanstack/cms-store-postgres (including per-collection storage); local disk or S3/R2 via @tanstack/cms-media-s3. Image resizing and WebP/AVIF with sharp.
  • A versioned API. /api/cms/v1 with an OpenAPI document, structured error codes, and @tanstack/cms-client, a typed fetch client inferred from your config, with TanStack DB bindings at @tanstack/cms-client/db.
  • Agents, your choice of model. Pass @tanstack/ai adapters for text and images; the conversational agent, on-page AI editing, and AI images appear only when they are configured. /api/mcp serves the CMS to any MCP client.
  • SEO built in. Sitemap, robots.txt, redirects, OpenGraph and JSON-LD helpers, and signed webhooks on publish, unpublish, and delete.
  • Routes from a package. The admin, public pages, and API endpoints mount into your Start app with createRoutes(definition). Mount only some, move the admin under a base path, or replace or drop any route by its key.
  • A CLI. tanstack-cms init, migrate, seed, export, import, and backup.

Packages

Package Description
@tanstack/cms-core The engine: defineCms, schema, roles, storage and media adapters, workflow, SEO, webhooks. No React.
@tanstack/cms-api Operations registry, TanStack Start server functions, the HTTP handler, the MCP server, and the markdown loader.
@tanstack/cms-ui-react The React admin and public UI, the TanStack Start route set, and the Vite plugin.
@tanstack/cms-client Typed fetch client for the HTTP API, and TanStack DB collections (/db).
@tanstack/cms-store-postgres PostgreSQL storage with pooled connections, JSONB, trigram search, and cascading foreign keys. Embedded (PGlite) dev variant at /pglite.
@tanstack/cms-media-s3 S3-compatible media adapter (AWS S3, Cloudflare R2, MinIO, B2).
@tanstack/cms-cli The tanstack-cms command line.
@tanstack/cms-ui-dom Experimental (0.x, outside the 1.0 semver guarantee). Framework-agnostic DOM/HTML-string renderers (blocks, Markdown, shells) + Svelte-friendly stores & use: actions.

A minimal app

// src/cms.definition.ts — the content model; safe to load anywhere
import {
  defineCmsDefinition,
  defineCollection,
} from '@tanstack/cms-core/definition'

const post = defineCollection({
  name: 'post',
  label: 'Posts',
  titleField: 'title',
  bodyField: 'body',
  path: (_doc, id) => `/post/${id}`,
  fields: [
    { name: 'title', label: 'Title', type: 'text', required: true },
    { name: 'body', label: 'Body', type: 'markdown' },
  ],
})

export const definition = defineCmsDefinition({ collections: [post] })
// src/cms.config.ts — the runtime: storage, auth, AI, ops, server-bound hooks
import { defineCms } from '@tanstack/cms-core'
import { definition } from './cms.definition'

export const cms = defineCms(definition, { blockTypes: [] })

declare module '@tanstack/cms-core' {
  interface Register {
    cms: typeof definition
  }
}

A small app can keep both halves in one defineCms({ collections, … }) call, but vite.config.ts mounts the routes from the definition, so keep at least defineCmsDefinition({}) in src/cms.definition.ts.

// vite.config.ts
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { nitro } from 'nitro/vite'
import viteReact from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { createRoutes } from '@tanstack/cms-ui-react/virtual-routes'
import { tanstackCms } from '@tanstack/cms-ui-react/vite'
import { definition } from './src/cms.definition'

export default defineConfig({
  plugins: [
    tanstackCms(),
    tailwindcss(),
    tanstackStart({ router: { virtualRouteConfig: createRoutes(definition) } }),
    nitro(),
    viteReact(),
  ],
})

Import ./cms.config from your router so the model is registered, then start the dev server: the admin is at /content.

Starters

TanStack CMS ships a 14-row starter catalog (12 application classes and 2 delivery modes) so every architectural seam (S1–S8) has a dedicated acceptance instance and every new project starts from a clean, right-sized starting point. Two classes also have full-depth banner apps — PRM (app/prm) for bespoke domain apps (#10, whose starter is Contact Cards at starters/contact-cards) and Data (app/base) for runtime-schema generated apps (#12, whose starter is Runtime Tables at starters/runtime-tables) — which serve as reference implementations rather than starter templates to clone. See starters/README.md, the machine-readable starters/catalog.json, and Choosing a Starter.

Examples

Example What it shows
blog The reference app: posts, pages, blocks, AI editing, and the Playwright suite.
blog-voting Extending the CMS with your own collections and routes (votes on posts).
db-sqlite, db-federated TanStack DB as the data layer: a writable CMS collection, and CMS copy joined with other services in one live query.
payload-after, astro-starlight-after, emdash-after, wordpress-after Sites migrated from Payload, Astro Starlight, EmDash, and WordPress, each next to its *-before source.

Migration skills

Each migration is an agent skill that discovers the source, scaffolds the TanStack CMS app, maps collections, fields, and blocks, migrates content, verifies parity, and writes a gap report:

See migration overview.

Developing this repo

pnpm install
pnpm dev            # examples/blog on http://localhost:3003
pnpm test:pr        # lint, types, unit tests, builds for affected packages
pnpm test:e2e       # Playwright against examples/blog
pnpm test:pack      # install the packed tarballs into a fresh app
pnpm test:coverage  # per-package coverage with thresholds

The blog example reads AI keys from examples/blog/.env.local (git-ignored): ANTHROPIC_API_KEY for text agents and GEMINI_API_KEY for images. Without them the AI features stay hidden. Content persists to examples/blog/.data/, seeded on first run.

Releases are cut with Changesets; see RELEASING.md.

License

MIT

About

Content Management System

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages