Guide

Project setup

For the full end-to-end guide (tokens, Vercel, webhooks, Umami, Resend), see getting-started.md.

Quick start

pnpm install
pnpm sanity:project-setup
# Edit .env.local with your Sanity project ID and tokens
pnpm sanity:project-setup --import-seed
pnpm dev

Environment variables

VariableRequiredPurpose
NEXT_PUBLIC_SANITY_PROJECT_IDYesSanity project (browser + server)
NEXT_PUBLIC_SANITY_DATASETYesUsually production
NEXT_PUBLIC_URLYesSite URL for SEO + Presentation Tool
SANITY_API_VIEW_TOKENFor previewDraft mode + live editing
SANITY_API_EDIT_TOKENFor formsWrite contact form submissions
SANITY_REVALIDATE_SECRETFor productionWebhook signature verification
RESEND_API_KEYOptionalEmail notifications for forms

NEXT_PUBLIC_* vars are required for embedded Studio — the browser cannot read SANITY_STUDIO_*.

Sanity webhook (production)

  1. sanity.io/manage → your project → APIWebhooks
  2. URL: https://your-domain.com/api/revalidate
  3. Dataset: production
  4. Trigger: Create, Update, Delete
  5. Secret: same as SANITY_REVALIDATE_SECRET in env
  6. Projection: { _id, _type, "uri": uri.current, "slug": slug.current }

CORS

Add your deploy URL (and http://localhost:3000) in sanity.io/manage → APICORS origins.