This guide takes you through the full cms0 loop.
You will create or open a runtime, publish a typed schema, edit content, and read it from a TypeScript app.
A runtime is either a hosted project environment or a self-hosted
@cms0/admin instance. The app integration code is the same after you have a
base URL and API key.
What you need
- Node.js 22 or newer.
- A TypeScript app.
- Access to a hosted cms0 workspace or a running self-hosted
@cms0/admin.
You will add these files to your app:
- cms0.config.ts
- cms0.ts
Create or open a runtime
Hosted workspace
Open the cms0 app, create an organization if needed, then create a project with at least one environment.
Open the environment page and copy the API base URL. It will look like one of these forms:
https://environment-key.your-domain.com/api
https://app.example.com/api/content/environment-keyCreate an API key
Create an API key from the runtime settings. Give it enough permission to publish schema and read/write content while you are setting up.
Store the key in your app environment:
CMS0_API_BASE_URL="https://environment-key.example.com/api"
CMS0_API_KEY="cms0_..."Keep CMS0_API_KEY server-side unless the key is deliberately scoped for
browser use.
Install the package
pnpm add @cms0/cms0Add a typed content entry
Create src/cms0.ts:
import { cms0 } from "@cms0/cms0";
import type { Image, Seo } from "@cms0/cms0/custom-types";
type RootSchema = {
homePage: {
headline: string;
heroImage?: Image;
seo?: Seo;
};
};
export const cms = cms0<RootSchema>({
apiConfig: {
baseUrl: process.env.CMS0_API_BASE_URL,
key: process.env.CMS0_API_KEY,
},
});Add the CLI config
Create cms0.config.ts at your app root:
import "dotenv/config";
import { defineConfig } from "@cms0/cms0/config";
export default defineConfig({
entry: "./src/cms0.ts",
api: {
baseUrl: process.env.CMS0_API_BASE_URL,
key: process.env.CMS0_API_KEY,
},
});Publish the schema
Run the local watcher while you build:
pnpm exec cms0 devFor CI or a one-time publish, run:
pnpm exec cms0 buildEdit content
Open the admin UI for the environment. You should see homePage as editable content. Fill in the headline and save.
Read content in your app
import { cms } from "./cms0";
const homePage = await cms.homePage();
console.log(homePage.headline);Success check
You are ready to keep building when all of these are true:
pnpm exec cms0 devpublishes without errors.homePageappears in the cms0 admin UI.- Saving content in cms0 changes the value returned by
cms.homePage().