Sanity Studio stuck on "Loading documents..." indefinitely
When Sanity Studio gets stuck on "Loading documents…" for a long time locally, this is usually a configuration issue. Here are the most common causes and solutions:
Check Your Configuration File
First, make sure your sanity.config.js (or sanity.config.ts) has the correct projectId and dataset configured. Using defineConfig, your config should look something like this:
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
export default defineConfig({
name: 'default',
title: 'My Studio',
projectId: 'your-project-id', // Make sure this is correct
dataset: 'production', // Make sure this matches your dataset
plugins: [
structureTool()
],
schema: {
types: [/* your schema types */]
}
})Environment Variables in Studio v3+
If you're using environment variables, note that Sanity Studio v3+ requires the SANITY_STUDIO_ prefix for environment variables to be accessible in the browser. Your .env file should look like:
SANITY_STUDIO_PROJECT_ID=your-project-id SANITY_STUDIO_DATASET=production
Then reference them in your config:
export default defineConfig({
projectId: process.env.SANITY_STUDIO_PROJECT_ID,
dataset: process.env.SANITY_STUDIO_DATASET,
// ... rest of config
})Common Issues & Solutions
- Missing or incorrect projectId/dataset: Double-check these values match your actual Sanity project
- Authentication issues: Run
sanity loginin your terminal to ensure you're authenticated - Corrupted node_modules or lock files: As mentioned in this community thread, sometimes re-cloning the project or running
npm install(oryarn install) fresh can resolve dependency sync issues - Schema errors: Check your browser console for any schema validation errors that might be preventing documents from loading
- CORS issues: If you're running Studio embedded in another app, ensure your project's CORS origins are configured correctly in your Sanity project settings
Quick Debugging Steps
- Check the browser console for specific error messages
- Verify your
projectIdanddatasetare correct in your config - Try running
sanity loginto refresh authentication - Clear your browser cache or try in an incognito window
- If using a starter template, try
npm installoryarn installto ensure dependencies are in sync
If you're still stuck after trying these solutions, check the browser console for specific error messages - they'll usually point you to the exact configuration issue.
Show original thread10 replies
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.