Project scaffolding: create-schma
The fastest way to start building with SCHMA is create-schma. It creates a ready-to-run frontend application pre-configured with @schmadev/client, environment variables, and TypeScript definitions.
npx create-schma@latest my-app
# Interactive prompt flow:
# ? Where would you like to create your project? my-app
# ? Which framework would you like to use? Next.js App Router (Recommended)
# ? What is your Schma API Key? sk_live_...
# ? What is your Tenant Slug? acme-corpFlags & non-interactive usage
For CI pipelines or automated setup scripts, pass flags to bypass interactive prompts:
# Scaffolding in automated scripts or CI
npx create-schma@latest my-app \
--template nextjs \
--api-key "YOUR_API_KEY" \
--tenant-slug "YOUR_TENANT_SLUG" \
--yes| Option | Description |
|---|---|
| -t, --template <type> | Framework template: nextjs (App Router) or vite. |
| -k, --api-key <key> | Schma API key to write into .env.local. |
| -s, --tenant-slug <slug> | Workspace tenant identifier. |
| -u, --api-url <url> | Base API URL (defaults to https://api.schma.dev). |
| -y, --yes | Skip prompts and apply defaults automatically. |
| --skip-install | Skip automatic package manager dependency installation. |
Developer CLI: @schmadev/cli
The developer CLI (schma) enables you to authenticate, link local directories to remote workspaces, and synchronize content model types.
# Install globally
npm install -g @schmadev/cli
# Or run directly on demand
npx @schmadev/cli --helpAuthentication (login)
Authenticate your development workstation with your SCHMA API key:
schma login
# Prompts for your SCHMA API key and validates permissions.
# Stores credentials securely in ~/.schmarcProject linking (link)
Link your local codebase to a remote SCHMA workspace tenant:
cd my-project
schma link
# Links your local repository directory to a remote workspace tenant.Type generation (generate)
The generate command introspects your remote PostgreSQL schemas and writes type-safe TypeScript interfaces:
# Generate TypeScript definitions from live PostgreSQL schemas
schma generate
# Or specify custom tenant and output path:
schma generate --tenant acme-corp --out src/types/schma.d.ts// schma-types.d.ts (Auto-generated by SCHMA CLI)
export interface BlogPost {
title: string;
slug: string;
excerpt?: string;
content: string;
publishedAt: string;
author: {
name: string;
avatarUrl?: string;
};
}
export interface Author {
name: string;
bio?: string;
email: string;
}CI/CD automation & schema drift detection
Run type generation in your pull request checks to prevent frontend code from breaking when content schemas evolve:
# .github/workflows/verify-schema.yml
name: Verify Schema Types
on: [pull_request]
jobs:
check-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Generate SCHMA types
env:
SCHMA_API_KEY: ${{ secrets.SCHMA_API_KEY }}
SCHMA_TENANT_SLUG: ${{ secrets.SCHMA_TENANT_SLUG }}
run: npx @schmadev/cli generate --out src/types/schma.d.ts
- name: Verify no diff
run: git diff --exit-code