Joint session with Vercel: How to build intelligent storefronts (May 15th)

Sanity Studio missing projectId despite .env.development configuration

11 repliesLast updated: Nov 29, 2025

Error: Configuration must contain `projectId`
    at exports.initConfig (/studio/static/js/app.bundle.js:188293:11)
    at SanityClient.config (/studio/static/js/app.bundle.js:183556:25)
    at new SanityClient (/studio/static/js/app.bundle.js:183524:8)
    at SanityClient (/studio/static/js/app.bundle.js:183521:12)
    at createClient (/studio/static/js/app.bundle.js:183266:64)
    at Object. (/studio/static/js/app.bundle.js:183216:43)
    at __webpack_require__ (/studio/static/js/vendor.bundle.js:713:30)
    at fn (/studio/static/js/vendor.bundle.js:118:20)
    at Object. (/studio/static/js/app.bundle.js:183064:39)
    at __webpack_require__ (/studio/static/js/vendor.bundle.js:713:30)
Getting this error out in my development instance of sanity. I’m loading an
.env.development
file into sanity to define projectId and dataset which looks like this:

# For Next
NEXT_PUBLIC_SANITY_PROJECT_ID="#######"
NEXT_PUBLIC_SANITY_DATASET="production"

# For Studio
SANITY_STUDIO_API_PROJECT_ID="#######"
SANITY_STUDIO_API_DATASET="production"
AI Update

The 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:

If 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.

Show original thread
11 replies

Was this answer helpful?

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.

Related contributions