Creating a Sanity project template with Next.js and Vercel
Absolutely! You can definitely turn your project into a reusable template. Here's how to create a template that you (and others) can use for future projects:
Creating a GitHub Template Repository
The simplest approach is to turn your repository into a GitHub template repository:
- Go to your repository on GitHub
- Click Settings
- Check the box that says "Template repository"
Now anyone (including you) can click "Use this template" to create a new project based on your setup. This is great for personal reuse and sharing with others.
Adding a Vercel Deploy Button
To make deployment even easier, you can add a Vercel Deploy Button to your repository's README. This allows one-click deployment to Vercel with environment variable prompts.
Add this to your README.md:
[](https://vercel.com/new/clone?repository-url=https://github.com/YOUR_USERNAME/YOUR_REPO&project-name=my-sanity-project&repository-name=my-sanity-project&env=NEXT_PUBLIC_SANITY_PROJECT_ID,NEXT_PUBLIC_SANITY_DATASET,SANITY_API_TOKEN&envDescription=Required%20Sanity%20environment%20variables&envLink=https://www.sanity.io/docs/api-versioning)Key parameters you can customize in the Deploy Button URL:
repository-url: Your GitHub repository URLproject-name: Default project name in Vercelenv: Comma-separated list of required environment variables (like your Sanity project ID, dataset name, and API tokens)envDescription: Help text shown to users about what these variables are forenvLink: Link to documentation explaining how to get these values
When someone clicks the Deploy Button, Vercel will:
- Clone your repository
- Prompt them to enter the required environment variables
- Deploy both your
webfolder to Vercel - Set up the project with all the necessary configuration
Creating an Official Sanity Template
If you want to share your template with the broader Sanity community, you can submit it as an official template. According to the Sanity documentation on creating templates, here's the process:
Use the Template Kit: Start with the official Sanity Template Kit or adapt your existing project to match its structure
Validate Your Template: The template kit includes a validation script to ensure it meets Sanity's requirements:
npm run validateSubmit for Review: Once validated, submit your template through the Community Studio
The validator checks for:
- Properly configured Sanity Studio
- Valid frontend setup with TypeScript support
- A
README.mdwith a "Getting Started" section with clear setup instructions - Proper environment variable configuration (
.env.exampleor.env.templatefiles)
Project Structure Best Practices
For your monorepo structure with studio and web folders, make sure to:
- Add
.env.examplefiles in both folders showing what environment variables are needed:
# studio/.env.example
SANITY_STUDIO_PROJECT_ID=your-project-id
SANITY_STUDIO_DATASET=production
# web/.env.example
NEXT_PUBLIC_SANITY_PROJECT_ID=your-project-id
NEXT_PUBLIC_SANITY_DATASET=production
SANITY_API_READ_TOKEN=your-read-tokenCreate a comprehensive README.md at the root with:
- Project description
- Prerequisites
- Setup instructions (clone, install, configure)
- How to run locally
- How to deploy
- Your schema structure (documents: works, tags, singleton: home)
Add a root
package.jsonwith helpful scripts:
{
"name": "next-sanity-starter",
"private": true,
"scripts": {
"dev": "concurrently \"npm run dev --prefix studio\" \"npm run dev --prefix web\"",
"install:all": "npm install --prefix studio && npm install --prefix web"
},
"devDependencies": {
"concurrently": "^8.0.0"
}
}Quick Personal Setup
For quick personal reuse, you could also create a simple setup script:
#!/bin/bash
# setup.sh - Run this after cloning
echo "Setting up your new Sanity + Next.js project..."
# Install dependencies
cd studio && npm install && cd ..
cd web && npm install && cd ..
# Copy environment templates
cp studio/.env.example studio/.env.local
cp web/.env.example web/.env.local
echo "✅ Setup complete! Next steps:"
echo "1. Add your Sanity project credentials to studio/.env.local and web/.env.local"
echo "2. Run 'npm run dev' to start both studio and web"Recommended Approach
For your use case, I'd recommend:
- Make it a GitHub template repository (easiest for creating new projects)
- Add a Vercel Deploy Button to your README (makes deployment super easy)
- Include clear
.env.examplefiles and setup documentation - Optionally, submit it as an official Sanity template if you want to share it with the community
The GitHub template + Vercel Deploy Button combination is the most user-friendly approach and exactly what you're looking for. When you want to start a new project, just click "Use this template" on GitHub, then click the Deploy Button to get it live on Vercel in minutes!
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.