Quickstart
Go from zero to a working Laizy CMS project in under five minutes.
Quickstart
This guide walks you through creating your first Laizy CMS project, defining a content model, syncing it to your database, and querying content with a type-safe client.
Prerequisites
- Node.js 22.x or later
- A Laizy CMS account (sign up at laizycms.com/request-access)
- An API token (generate one from your dashboard at
/dashboard/developer)
Step 1: Initialize your project
Run the init command in your project directory:
pnpm laizy initThis creates three things:
~/.laizyrc— Global config with your API token and base URLlaizy/schema.laizy— Your schema file where you define content models.laizy/project.json— Local project context linking to your Laizy project
The CLI will prompt you for your API token and let you select or create a project.
Step 2: Define your schema
Open laizy/schema.laizy and define your first content model:
model BlogPost {
title: String {
required: true
maxLength: 200
}
content: String {
required: true
}
slug: String {
required: true
unique: true
}
status: String {
default: "draft"
}
}
model Author {
name: String {
required: true
maxLength: 100
}
email: String {
required: true
unique: true
}
bio: String
}Each model block defines a content type. Fields have a name, a type, and optional constraints inside curly braces.
Step 3: Preview and sync
First, preview what the sync will do:
pnpm laizy sync --dry-runYou'll see a migration plan showing which models will be created, updated, or deleted. When you're ready:
pnpm laizy syncThe CLI analyzes your schema, generates a migration plan, shows you an impact summary, and asks for confirmation before applying changes.
Step 4: Generate the TypeScript client
pnpm laizy generateThis creates three files in your configured output directory (default: generated/laizy/):
| File | Purpose |
|---|---|
types.ts | TypeScript interfaces for each content model |
client.ts | Client class with Prisma-like query methods |
index.ts | Re-exports everything for clean imports |
Step 5: Query content in your app
import { LaizyClient } from './generated/laizy';
import { ManagementClient } from '@/lib/management-client';
// Create a management client with your API token
const managementClient = new ManagementClient({
baseUrl: 'https://laizycms.com',
apiToken: process.env.LAIZY_API_TOKEN!,
});
// Create the typed client
const client = new LaizyClient(managementClient);
// Fetch all published blog posts
const posts = await client.blogPost.findMany();
// Fetch a single post by ID
const post = await client.blogPost.findById('abc123');
// Count posts
const total = await client.blogPost.count();The generated client gives you full autocomplete — every model, field, and method is typed.
Step 6: Create content
You can create content through the CLI, the dashboard, or the AI chat:
# Via CLI
echo '{"title": "Hello World", "content": "My first post", "slug": "hello-world"}' \
| pnpm laizy content create BlogPost --status publishedOr use natural language in the dashboard's AI chat:
"Write a blog post about our new API features and publish it"
Next steps
- Core Concepts — Understand the mental model behind projects, schemas, and tokens
- Schema Syntax — Full reference for the
.laizyschema language - CLI Reference — Every command and option
- Authentication — Token types, scopes, and how to generate them