GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

CMS

Edit Markdown documents in the Console, keep every draft, and publish to your site or a pull request.

The CMS is vite-hub/cms, built on Content. Add extends: cms to server/content.ts to store your document collections. It turns on Workspace, Database, and Blob, adds the Workspace and its history tables, and adds a Database when your app has none. You write no Workspace, Database, or schema code.

import { defineContent } from 'vite-hub/content'
import { documents } from 'vite-hub/content/collections'
import { cms } from 'vite-hub/cms'
import { z } from 'zod'

export default defineContent({
  extends: cms,
  collections: {
    posts: documents({ path: 'posts/**/*.md', fields: { title: z.string() } }),
  },
})
server/content.ts

Start with the Blob + Database store. One option changes the store, and the collections stay the same.

SetupYou addYou get
Blob + Database storeextends: cms in server/content.tsDrafts, revisions, and published documents in your Blob store and Database, plus scheduled publishing. Runs wherever Blob and Database work, with no GitHub access.
GitHub store, commits to mainextends: [cms, { repo: 'owner/name' }], and VITEHUB_GITHUB_TOKENDocuments are files in your repository. A save is a commit on the vitehub/content draft branch. A publish is one commit on main. Checkout and Console edits meet in Git. No Blob store.
GitHub store with pull requestspublish: 'pr' in the same optionsA publish opens a pull request into main. Review it, wait for checks, and merge it any way you like. The Console shows the link until it merges.

One line selects the preset

Add extends: cms to server/content.ts with no extra settings.

No wiring to write

The preset adds the Workspace, its history tables, and a Database if needed. vitehub inspect definitions lists each piece.

Keep content in Git

Set repo to keep published documents and drafts on separate branches, where each publish is a commit.

Publish through pull requests

publish: 'pr' opens a pull request for each publish, keeping documents pending until it merges.

Decide who edits and publishes

Set roles: true and assign viewer, commenter, editor, or publisher roles, or write your own authorize.

Edit in the Console

Editors open the Content section of the Console to edit fields and body text, compare versions, and publish reviewed changes.

The CMS stores your collections. Content does the rest, on both stores:

  • Roles and access: give each user a role with the Better Auth admin plugin.
  • Hosts: where each store runs and what to provision before a hosted deploy.
  • Limits and errors: GitHub store limits and fixes for each error code.
  • Server API: package exports and every preset option.