All Systems Operational
Powered By
profound-logo
profound-logoProfound CMS
⌘K
Admin

Quickstart

A post about schemas

Continue Reading
NextJson And Claude Code›

Generate Type-Safe Zod Schemas

This feature allows you to get your schema description in the form of a type-safe Zod schema, providing:

  • TypeScript-first schema validation
  • Static type inference

Learn more: https://zod.dev

Setup

To pull your Zod schema, you will:

  1. Load required dependencies
  2. Create a script using utilities from cms-renderer

Project Structure

apps/
  web/
    app/
      page.tsx
    scripts/
      generated-schema.ts   # script file

Script: generated-schema.ts

import { fetchAllCustomSchemaFields, saveZodSchemaCode } from 'cms-renderer/lib/custom-schemas';
import { cmsConfig } from '../lib/cms-config';

async function main() {
  const { cmsUrl, websiteId } = cmsConfig;

  if (!cmsUrl) {
    throw new Error(
      '[generate-schemas] NEXT_PUBLIC_CMS_API_URL is not set. Set it in your environment or .env file.'
    );
  }

  if (!websiteId) {
    throw new Error(
      '[generate-schemas] CMS_WEBSITE_ID is not set. Set it in your environment or .env file.'
    );
  }

  await saveZodSchemaCode(
    await fetchAllCustomSchemaFields(cmsConfig),
    './generated/cms-schemas.ts'
  );

  console.log('[generate-schemas] Done.');
}

main().catch((err) => {
  console.error('[generate-schemas] Failed:', err);
  process.exit(1);
});

CMS Config Example

export const cmsConfig = {
  cmsUrl: process.env.NEXT_PUBLIC_CMS_API_URL,
  apiKey: process.env.CMS_API_KEY,
  websiteId: '...',
};

package.json Configuration

Note: If you don't have a tsconfig.json, remove the --tsconfig flag.

{
  "name": "web",
  "version": "0.1.0",
  "type": "module",
  "private": true,
  "scripts": {
    "generate-schemas": "tsx --tsconfig tsconfig.json scripts/generate-schemas.ts",
    "...": "..."
  },
  "dependencies": {

Running the Script

bun run generate-schemas

Example output:

tsx --tsconfig tsconfig.json scripts/generate-schemas.ts
[generate-schemas] Done.

Updated Project Structure

apps/
  web/
    app/
      page.tsx
    scripts/
      generated-schema.ts
    generated/
      cms-schemas.ts   # generated Zod schema

Usage in page.tsx

import type { PetFoodPost, SiteConfig } from '@/generated/cms-schemas';
import { petFoodPostSchema } from '@/generated/cms-schemas';

// Use for type-safe parsing
petFoodPostSchema.parse(obj);

Notes

  • Inspect the generated file to understand your schema structure
  • Re-run the script whenever your schema changes:
bun run generate-schemas
  • You can integrate this into your dev or build workflow
  • Update schemas via the admin panel, then regenerate locally
"cms-renderer"
:
"0.3.1"
,
"zod": "^4.3.6",
"...": "..."
},
"devDependencies": {
"tsx": "^4.21.0",
"object-hash": "^3.0.0",
"...": "..."
}
}

Hybrid

Setup Hybrid CMS ProjectParametric Pages with ComponentsTypes of ComponentsSetup server sent events (SSE) content refetchSetup admin panel proxyStatic Rendering with Edit Mode SupportScripting in Template BuilderGetting Started Hybrid

Headless

Quick startSplit Screen JSON Component Builder with LLMComponent Zod Pull

MCP

MCP with Claude Code / Codex

Feature

Documentation Site TemplateFeature Template BuilderTranslation ServiceOrganizations & Website Heirarchy

Motivation

Our Approch

Terminology

'Hybrid' vs 'Headless'