Guide

Commands

All pnpm scripts and common workflows for this starter.

Development

CommandDescription
pnpm devStart Next.js dev server with Turbopack. Site at /, Studio at /studio.
pnpm buildProduction build.
pnpm startRun the production build locally.

Code quality

CommandDescription
pnpm checkRun Biome lint and format check on the whole project.
pnpm check:typesTypeScript type check (tsc --noEmit).
pnpm formatAuto-fix lint and format issues with Biome.

Pre-commit hooks (via Lefthook) run biome check on staged files and check:types automatically. See features/git-hooks.md.

Project setup

CommandDescription
pnpm sanity:project-setupCreate .env.local from .env.example, validate required env vars, print next steps.
pnpm sanity:project-setup --import-seedSame as above, then import seed/production.ndjson.

Sanity CLI

CommandDescription
pnpm sanity:cli <args>Run the Sanity CLI (alias for sanity).

Common Sanity CLI usage:

pnpm sanity:cli login
pnpm sanity:cli deploy          # deploy standalone Studio (not needed for embedded /studio)
pnpm sanity:cli dataset list
pnpm sanity:cli documents query '*[_type == "page"][0..5]'

Schema & types

CommandDescription
pnpm sanity:typegenExtract schema to sanity-schema.json, then generate TypeScript types.

Run after any schema change:

pnpm sanity:typegen

Output updates features/sanity/sanity.types.ts (via Sanity TypeGen config).

Dataset management

CommandDescription
pnpm sanity:dataset-importImport seed/production.ndjson into your configured dataset (--replace).
pnpm sanity:dataset-exportExport dataset backup to ./backups/.
pnpm sanity:dataset-migrateCopy one dataset to another (interactive confirmation).

See sanity/dataset-migration.md.

Warning: --replace on import overwrites existing documents with matching _id values.


Code generation (Plop)

Scaffold new page-builder sections without hand-editing multiple registry files.

pnpm plop

Choose page-builder-section and answer the prompts:

PromptExample
Section name (kebab-case)text-banner
Studio titleText Banner Section
Sanity iconBlockElementIcon

What gets created

  • sanity/schemas/page-sections/{name}-section.ts — Studio schema
  • features/page-builder/sections/{name}-section.tsx — React component
  • Registry updates in:
    • sanity/schemas/page-sections/index.ts
    • sanity/schemas/index.ts
    • features/page-builder/page-sections.tsx
    • features/sanity/queries.ts

After generating

pnpm sanity:typegen
pnpm dev

Add the new section type in Studio → Page → Sections, then verify it renders on the frontend.

See features/code-generation.md.


Common workflows

First-time setup

pnpm install
pnpm sanity:project-setup
# edit .env.local
pnpm sanity:project-setup --import-seed
pnpm dev

After changing a schema field

pnpm sanity:typegen
pnpm dev

After adding a new page-builder section

pnpm plop
pnpm sanity:typegen
pnpm dev

Before committing

Hooks run automatically. To run manually:

pnpm check
pnpm check:types

Backup production content

pnpm sanity:dataset-export

Production build locally

pnpm build
pnpm start

Script source files

ScriptImplementation
sanity:project-setupscripts/sanity-project-setup/setup.ts
sanity:dataset-importscripts/sanity-dataset/import.ts
sanity:dataset-exportscripts/sanity-dataset/export.ts
sanity:dataset-migratescripts/sanity-dataset/migrate.ts
plopplopfile.mjs + templates/page-builder-section/