Environment Variables Template
Environment Variables Template
Section titled “Environment Variables Template”Copy this template to create your .env
file in the root directory:
# EnvironmentNODE_ENV=developmentPORT=8080
# Sanity ConfigurationNEXT_PUBLIC_SANITY_PROJECT_ID=your_project_id_hereNEXT_PUBLIC_SANITY_DATASET=productionNEXT_PUBLIC_SANITY_DATASET_DEV=developmentSANITY_API_VERSION=2024-03-21SANITY_API_TOKEN=your_api_token_here
# Sanity Studio Environment VariablesSANITY_STUDIO_PUBLIC_SANITY_PROJECT_ID=your_project_id_hereSANITY_STUDIO_PUBLIC_SANITY_DATASET=productionSANITY_STUDIO_PUBLIC_SANITY_DATASET_DEV=development
How to Use
Section titled “How to Use”- Copy the template above
- Create a
.env
file in your project root - Replace the placeholder values with your actual Sanity project details
- Save the file
- Restart your development environment
Getting Your Values
Section titled “Getting Your Values”Project ID
Section titled “Project ID”- Found in your Sanity project dashboard
- Looks like:
abc12345
API Token
Section titled “API Token”- Go to Sanity project → API → Add API token
- Role: Editor
- Copy the generated token
Datasets
Section titled “Datasets”- Create these in Sanity project → Datasets
- Common names:
production
,development
,testing
Security Notes
Section titled “Security Notes”- Never commit your
.env
file to version control - Keep your API tokens secure
- Use different tokens for development and production
- Rotate tokens regularly