How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Next.js with Sanity

A clean example of Next.js with Sanity with live previews.

By Marius Lundgård


README

sanity-template-nextjs

This is a template for new projects using Next.js with embedded Sanity integration and Sanity Studio on the /studio route.

NOTE: This template intentionally does NOT use Next.js’s experimental appDir feature since there are known issues with this. I’ll wait until their appDir feature is stable.

Features

  • Live previews using next-sanity.
  • Customized Sanity Desk Tool.
  • Just TypeScript.
  • Eslint configuration.
  • Environment variables.
  • Tailwind.

Getting started

Initialize project

# Install dependencies
pnpm install

# Create a Sanity project ID and dataset and write to `.env.local`
pnpm exec sanity init --env .env.local

# Start development server
pnpm dev