Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
An example of a Sanity powered frontend using Next.js
Sanity + Next.js Frontend Example is a boilerplate template that demonstrates how to build a Next.js frontend powered by the Sanity headless CMS, using the movie dataset as sample content.
This starter repository pairs Next.js, the React-based framework from zeit (now Vercel), with Sanity's headless content platform. It provides a minimal, working frontend that pulls content from a Sanity dataset and renders it into web pages. The template expects a Sanity project seeded with the example movie dataset, and it exposes configuration in lib/sanity.js where you set project ID and dataset name. It's maintained by Sanity on GitHub (sanity-io/example-frontend-next-js) and requires Node.js version 8.0 or greater.
This template includes the core plumbing needed to connect a Sanity dataset to Next.js pages, plus local development tooling.
This template is for developers who want a reference implementation of a Sanity-powered Next.js frontend, without building the integration from scratch.
The template follows a straightforward setup: clone or download the repo, run npm install to fetch dependencies, edit lib/sanity.js to insert your Sanity project ID and dataset name, enable CORS for localhost:3000, and then start the app with npm run dev. The Next.js server will render pages that fetch content from Sanity at runtime.
Sanity's example movie dataset contains movie and person content types, used to demonstrate how Sanity content can be rendered in a Next.js app. The template is pre-configured for this schema, so you can run it as-is against the default dataset.
Yes. Open lib/sanity.js and replace the project ID and dataset name with values from your own Sanity project, then run the dev server. You also need to add http://localhost:3000 to your project's CORS Origins settings.
Node.js version 8.0 or greater is needed to install dependencies and run the project with npm. The template's documentation specifies this version as the minimum.
