Gatsby build issues with Sanity blog starter project
Hey! Gatsby build issues with Sanity starters can definitely be frustrating. Based on what you're experiencing, there are a few common culprits to check:
Most Common Build Errors
1. Missing or Invalid Token for overlayDrafts
If you're seeing overlayDrafts is set to true, but no token is given, you need to add an API token to your gatsby-source-sanity configuration. Create a read token from the API tab in your Sanity project and add it to your gatsby-config.js:
{
resolve: 'gatsby-source-sanity',
options: {
projectId: 'your-project-id',
dataset: 'production',
token: 'your-read-token-here',
overlayDrafts: true,
watchMode: true
}
}2. GraphQL API Not Deployed
The ERROR #gatsby-source-sanity_drafts.10001 error means your GraphQL API hasn't been deployed yet. Run this from your Sanity Studio directory:
sanity graphql deploy3. Plugin Compatibility Issues
If you're getting window.URL.createObjectURL errors, this is typically caused by outdated plugins. The sanity-plugin-mapbox-input plugin has a known issue with newer versions of mapbox-gl. This plugin is no longer maintained, so you'll need to either:
- Pin
mapbox-glto a compatible version in your package.json - Find an alternative plugin for map functionality
- Remove the plugin if you're not using it
4. Outdated Packages
The Sanity blog starter might be using older versions. Check your package versions:
npm ls gatsby-source-sanityThe latest gatsby-source-sanity version should be compatible with recent Gatsby versions. Consider updating:
npm update gatsby-source-sanityQuick Troubleshooting Steps
- Make sure your GraphQL API is deployed:
sanity graphql deploy - Add a read token to your gatsby-source-sanity config
- Check for outdated or unmaintained plugins (especially mapbox-related ones)
- Clear Gatsby cache:
gatsby clean - Rebuild:
gatsby build
If you're still having issues, sharing the specific error message would help diagnose further. The Sanity Discord community is also super helpful for real-time troubleshooting!
Show original thread12 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.