
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe issue is with your environment variable naming! Sanity Studio v3 uses a specific naming convention for environment variables, and you've got a slight mismatch.
Your environment variables should be named SANITY_STUDIO_PROJECT_ID and SANITY_STUDIO_DATASET (not SANITY_STUDIO_API_PROJECT_ID and SANITY_STUDIO_API_DATASET).
Here's how your .env.development file should look:
# For Next.js
NEXT_PUBLIC_SANITY_PROJECT_ID="#######"
NEXT_PUBLIC_SANITY_DATASET="production"
# For Studio
SANITY_STUDIO_PROJECT_ID="#######"
SANITY_STUDIO_DATASET="production"Then in your sanity.config.js or sanity.config.ts, you can reference them in your defineConfig like this:
import { defineConfig } from 'sanity'
export default defineConfig({
projectId: process.env.SANITY_STUDIO_PROJECT_ID,
dataset: process.env.SANITY_STUDIO_DATASET,
// ... rest of your config
})Important notes:
SANITY_STUDIO_ to be accessible in your Studio code.env.development loads when running sanity start, and .env.production loads during sanity build or sanity deploy.env file, restart your dev server for the changes to take effectIf you want to use different variable names (like SANITY_STUDIO_API_PROJECT_ID), you'll need to explicitly map them in your config file, but the standard convention as documented in the Sanity environment variables docs is SANITY_STUDIO_PROJECT_ID and SANITY_STUDIO_DATASET.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store