How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Sanity "Configuration must contain projectId" Error

9 repliesLast updated: Nov 29, 2025

AI Update

This error means your Sanity Studio configuration is missing the projectId value, which is required to connect to your Sanity project. Here's how to fix it:

Quick Fix

import {defineConfig} from 'sanity'

export default defineConfig({
  projectId: 'your-project-id-here', // ← Add this
  dataset: 'production',
  // ... rest of your config
})

If You're Using Environment Variables

For Next.js or other frameworks, you might be using environment variables. Make sure:

NEXT_PUBLIC_SANITY_PROJECT_ID=your-project-id-here
NEXT_PUBLIC_SANITY_DATASET=production

Note: In Next.js, the NEXT_PUBLIC_ prefix is required for client-side access.

import {defineConfig} from 'sanity'

export default defineConfig({
  projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
  dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,
  // ... rest of your config
})

Common Gotchas

Once you add the correct projectId to your configuration, the error should disappear and your Studio will load properly!

Show original thread
9 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