Your First Project
Follow this step-by-step guide to scaffold a BeechCMS edge backend, visually model your content schema, and query published entries with the official SDK in just 5 minutes.
Architecture overview
BeechCMS eliminates server management by running natively on Cloudflare's serverless primitives:
1. Project scaffolding
Generate a new BeechCMS project using the scaffolding CLI:
$ pnpm dlx @beechcms/cms@latest my-appAutomated setup
To skip interactive prompts and scaffold immediately with sensible defaults:
npx @beechcms/cms@latest my-app --yes
cd my-app
npm run devThe scaffolder installs the dependencies for you (pass --no-install to skip that).
Project layout
my-app/
├── worker.ts # Cloudflare Worker entry point delegating to @beechcms/api
├── wrangler.jsonc # Cloudflare bindings (D1, R2, Assets, environment vars)
├── .dev.vars # Local development secrets (git-ignored)
├── tsconfig.json # TypeScript configuration for Workers runtime
└── package.json # Project dependencies and operational scriptsThe entire CMS engine and admin SPA live inside @beechcms/api. Your workspace remains minimal and focused purely on configuration.
2. Local environment setup
Launch the dev server
npm run devnpm run dev first applies every pending system migration to your local Cloudflare D1 emulator (the same as npm run db:migrate:local, or npx beech db:migrate), then starts the local Workers runtime on http://localhost:8789. Nothing needs to be provisioned on Cloudflare to run locally, and media uploads work out of the box.
Open dashboard
Open http://localhost:8789/admin in your browser. Complete the initial setup by creating your administrator credentials.
3. Visual Seed modeling
BeechCMS models content through Seeds (Blueprints) containing Branches (Fields).
Create the Posts Seed
- In the Admin Dashboard navigation, click Content Modeling (or Seeds).
- Click Create Seed and configure the blueprint:
- Label:
Posts - Slug:
posts - Display Name Branch:
title - Public Read Access: Toggle ON (
allowPublicRead: true) to enable public REST API queries. - Drafts Workflow: Toggle ON (
allowDrafts: true) to enable dual-table draft staging.
- Label:
Configure Branches
Add the following Branches to the Seed:
- Title: Type
text, aliastitle, required, search indexed (search: true). - Cover Image: Type
file, aliascover_image, acceptimage. - Body: Type
richtext, aliasbody.
Do not add a slug branch. Every entry already has a slug system column, generated from the title (Hello BeechCMS becomes hello-beechcms), and the API rejects branch aliases that collide with system columns (id, slug, status, created_at, updated_at, deleted_at).
Click Save Seed. Under the hood, the Botanical Engine compiles the SQLite DDL: provisioning content_posts, the draft mirror table content_posts_drafts, B-tree indexes, and the full-text search virtual table fts_posts.
TIP
AI-Assisted Modeling: Prefer using an AI coding assistant in your editor? You can connect Cursor, Claude Desktop, Antigravity, or VSCode to create and evolve seeds automatically via the native AI & MCP Setup.
4. Publish content
BeechCMS guarantees draft isolation using Dual-Table Mirror Staging:
Dual-Table Mirror Staging
- Draft Table (
content_posts_drafts): Every draft save or live edit is written to the staging table. Editors can preview unpublished drafts safely without leaking unapproved changes. - Production Table (
content_posts): When you click Publish, BeechCMS atomically promotes the staging record into the production table. - Public API Safety: Public queries (
GET /api/v1/public/posts) query ONLY the production table by default. The internal routeGET /api/content/postsrequires authenticated admin session permissions.
Publish your first post
- Navigate to Content > Posts in the dashboard and click New Entry.
- Fill in the title
"Hello BeechCMS", write some body text, and click Publish.
NOTE
Public API reads are edge-cached for 60 seconds and publishing does not purge the cache, so a deployed site can show the previous content for up to a minute after you publish. See Response headers and caching.
5. Invite your team
The account you created during setup is the Developer / instance owner — the only account that can evolve schemas. Everyone else is onboarded through scoped RBAC: an account plus one or more (role, scope) assignments.
Open Settings → Access. Three entries appear there, each gated by what you hold:
| Tab | Visible when | What it does |
|---|---|---|
| Users | manage_users on any scope | Create accounts, assign roles per scope, deactivate |
| Roles | manage_users or manage_roles on any scope | Author permission bundles |
| Invitations | manage_users on any scope | Send, regenerate and revoke 72-hour invite links |
Create a role
In Roles → Create role, give it a name, pick an icon, and tick permissions grouped as Content (content:read, content:create, content:update, content:delete) and System (manage_users, manage_roles, manage_layout, manage_seeds, view_analytics).
For a blog editor, content:read + content:create + content:update is enough. A permission you do not hold yourself is disabled in the form — you can never mint a role more powerful than you are.
SuperAdmin is seeded by migration with the full set and is read-only: its edit and delete buttons are permanently disabled.
Option A — create the account directly
Users → Create account asks for email, password, name and surname. The account is created zero-trust: it has no role, no scope and sees nothing until you assign one. It appears in the table as No access.
Click the account's roles button, pick the role and a scope — either a single seed (posts) or All seeds (global) — and add the assignment. The scope dropdown only ever lists scopes you may grant on.
Option B — invite by email
Invitations → Invite takes the email plus the same (role, scope) pair, then emails a link valid for 72 hours. No account exists until the invitee redeems it.
The invitee lands on /admin/accept-invite?token=…, sees "you were invited as Role on Scope", chooses a password, and is sent to the login page. Their authority is re-checked at that moment: if you were deactivated or lost the permission in the meantime, the invitation stops working.
Rows show a derived status — pending, expired or accepted — with actions to regenerate (a fresh token and a new 72-hour window) or revoke.
NOTE
Invitations need a configured email provider. Locally that is Mailpit (EMAIL_PROVIDER=smtp, SMTP_HOST=localhost, SMTP_PORT=8025); in production, RESEND_API_KEY. Without either, the invite button returns email-unavailable. Option A works with no email configured at all.
Full model and API: Roles & Permissions and the RBAC Administration API.
6. Query with SDK
Connect your frontend to BeechCMS using the official @beechcms/client SDK.
Install the SDK
$ pnpm add @beechcms/clientFetch published posts
Create a script or module to query your published entries:
import { createBeechServerClient } from '@beechcms/client/server'
import { renderRichText } from '@beechcms/client/richtext'
interface Post {
id: string
title: string
slug: string
cover_image?: string
body: string | Record<string, unknown>
created_at: number
updated_at: number
}
interface AppRegistry {
posts: Post
}
// Initialize the Beech client with baseUrl and secretKey
const client = createBeechServerClient<AppRegistry>({
baseUrl: 'http://localhost:8789', // Your Worker URL
secretKey: 'beech_sk_dev' // BEECH_SECRET_KEY from .dev.vars (local only; read it from the environment in real code)
})
async function fetchPosts() {
const result = await client
.collection('posts')
.orderBy('created_at', 'desc')
.limit(10)
.list()
if (result.error) {
console.error('Failed to fetch posts:', result.error.detail)
return
}
const posts = result.data.data
console.log('Published Posts:', posts)
// Example: Convert TipTap richtext to HTML
if (posts[0]?.body) {
const html = renderRichText(posts[0].body)
console.log('Rendered HTML:', html)
}
}
fetchPosts()Refine the query
collection(seed) returns a chainable query builder. Each method compiles to the Public API query string — there is no second query language to learn:
// Filter, search, project, paginate
const result = await client
.collection('posts')
.where({ status: 'published', views: { gte: 100 } })
.search('edge rendering')
.select(['id', 'title', 'slug'])
.orderBy('created_at', 'desc')
.limit(12)
.page(1)
.list()
// A single entry by slug — .first() returns a 404 problem when nothing matches
const post = await client.collection('posts').where({ slug: 'hello-world' }).first()
// Pull related entries in the SAME request instead of an N+1 follow-up
const withAuthor = await client
.collection('posts')
.where({ slug: 'hello-world' })
.include(['author'])
.first()
// → entry.author holds the raw id, entry._includes.author holds the expanded record
// Filter through a relation, resolved server-side
const byAuthorName = await client
.collection('posts')
.whereRelation('author', { where: { name: { contains: 'Jane' } } })
.list()TIP
Stop hand-writing the row interfaces above: npx beech types generate reads the live schema and writes beech.generated.ts. Pass its BeechDatabase type as the client generic and every seed slug, field name, and sort key becomes compile-checked. Full reference: Client SDK.
7. Cloudflare edge deployment
When you are ready to deploy your production edge CMS to Cloudflare:
Authenticate with Wrangler
npx wrangler loginProvision edge resources
Let the Beech CLI provision your D1 database, R2 media bucket, and secrets:
npx beech setup:cloudflareDeploy to Workers
npx beech deployYour CMS API and embedded Admin Dashboard are now live worldwide on Cloudflare's global edge network with zero cold starts!
Next steps
- Explore Schema Modeling & Evolution for advanced field types and relations.
- Move your content model into reviewable code with a
beech.schema.tsmanifest. - Read the Client SDK reference for the full query builder, relation expansion, and typed registries.
- Set up your team with Roles & Permissions — scopes, invitations, and anti-escalation rules.
- Connect your AI assistant via AI & MCP Setup to inspect and evolve content models directly from your editor.
- Connect your frontend with dedicated Framework Quickstarts.
- Learn about Field Policies & ALE Encryption.