headcode

Docs · Installation

Run it locally

Everything on your laptop with one command. No Docker, no external Postgres. Embedded Turso compiles right into the Rust binary.

Installation/Local

1. Install the tools

  • Node.js and pnpm for the Next.js site
  • Rust with rustup for the mstack backend

2. Start backend and site

Terminal
git clone https://github.com/headcodecms/headcodecms.git
cd headcodecms
pnpm install
pnpm dev

Two local processes start together:

  • localhost:3080: the single-tenant Rust MCP backend (/mcp, /live, /media, /health) with an embedded Turso .db file
  • localhost:3082: the Next.js website and its /admin UI

3. Push schema, seed content, and mint your admin invite

Generate headcode.schema.json and headcode.seed.json from your Zod definitions, load them into Turso, and create your first zero-PII admin invite:

Terminal
pnpm --dir apps/base schema
cd apps/backend
cargo run -- schema ../base/headcode.schema.json
cargo run -- seed ../base/headcode.seed.json
cargo run -- invite create admin "Owner"

Open the printed http://localhost:3082/admin?invite=<token> URL in your browser to sign in through Better Auth and claim the admin role.

4. Enable signed cache revalidation

When you publish in Headcode, the backend sends an HMAC-signed webhook (x-mstack-signature / x-mstack-timestamp) to refresh cached Next.js pages immediately:

Terminal
echo "HEADCODE_REVALIDATE_SECRET=$(openssl rand -hex 32)" >> apps/base/.env.local
cd apps/backend
HEADCODE_REVALIDATE_SECRET="$(grep ^HEADCODE_REVALIDATE_SECRET= ../base/.env.local | cut -d= -f2)" \
  cargo run -- site http://localhost:3082/api/revalidate

Or let your agent do it

Prompt
Run Headcode CMS locally from github.com/headcodecms/headcodecms.
Export the schema and seed entries, load them into embedded Turso, create an initial admin invite,
and configure signed cache revalidation for http://localhost:3082/api/revalidate.

Verify everything end to end with pnpm lint && pnpm typecheck && pnpm test, or take it live with Uncloud & Vercel or full self-hosting. Full flags live in the README.