A minimal scaffolding template for creating your own Sanity template. Intended for template creators — customize as needed!
├── frontend/ # Your frontend application
├── studio/ # Sanity Studio
└── package.json # Root workspace configuration
A more in-depth guide is available in the Sanity documentation. Need inspiration or help creating a template? Join the #template-creators channel in Sanity’s Slack community to connect with others and get feedback.
Clone the template repository to your local machine.
npm installInstall your preferred frontend framework. The command below installs a new Next.js project in the frontend directory.
npx create-next-app@latest frontendThe frontend package is already defined as a workspace in the root package.json, but you may need to customize as needed.
Create an .env.example file in your frontend directory with the following variables:
SANITY_PROJECT_ID=
SANITY_DATASET=For Next.js projects, prefix the variables with NEXT_PUBLIC_:
NEXT_PUBLIC_SANITY_PROJECT_ID=
NEXT_PUBLIC_SANITY_DATASET=npm run devTo deploy your Sanity Studio to production:
- Make sure you're logged in to your Sanity account:
npx sanity login- Deploy the studio:
npm run deploy:studioYou have the freedom to deploy your app to your hosting provider of choice. With Vercel and GitHub being a popular choice, we'll cover the basics of that approach:
- Create a GitHub repository from this project. Learn more.
- Create a new Vercel project and connect it to your Github repository.
- Set the Root Directory to your
frontenddirectory. - Configure your Environment Variables.
npm run validateThis command ensures the Sanity CLI can properly read your template configuration.
For details on the template validator, visit sanity-io/template-validator.