Skip to main content

Next Sanity Starter

Get started

You need Node.js, pnpm and a Sanity project. Everything else ships in the repository, and the README lists the exact versions.

Run it locally

  1. Clone the repository and run pnpm install in its root folder.
  2. Copy web/.env.example to web/.env.local and studio/.env.example to studio/.env.
  3. Enter your Sanity project ID as SANITY_STUDIO_PROJECT_ID in both files. Locally, that is the only required value.
  4. Run pnpm dev. The site opens on port 3000, the Studio on port 3333.
  5. In the Studio, open Settings, then Site languages, and publish. Until you do, the site only knows English.

Add your own content block

Every content block is a module with two halves: a Sanity schema and a React component. pnpm gen:module Quote creates both, writes the query and registers the module in the six places it needs.

Then run pnpm generate. It writes the TypeScript types, so the component knows every field the query returns.

Put it online

The repository contains two Netlify configurations, one for the site and one for the Studio. Create two Netlify sites from the same repository and set the Studio’s package directory to studio.

Production deploys read the production dataset. Previews and branch deploys read development, so a test never touches live content.

Last, add a webhook in Sanity that points at /api/revalidate on your site. A publish then shows up on the next reload. The README lists every environment variable and what it does.