
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a known issue that occurs when your Sanity schema contains code that references browser-specific globals like document or window, which aren't available in the Node.js environment where the GraphQL deploy command runs.
The good news is that your deployment is actually succeeding despite the error! The "✔ Deploying GraphQL API" and "GraphQL API deployed to..." messages confirm this. The error happens during the validation step but doesn't block the actual deployment.
Common causes:
document, window, or other browser APIsHow to fix it:
The best approach is to wrap any browser-specific code in conditional checks:
// In your schema files
const MyComponent = () => {
if (typeof document !== 'undefined') {
// Browser-only code here
}
}Or use lazy loading for components:
components: {
input: typeof document !== 'undefined'
? require('./MyCustomInput').default
: undefined
}Debugging steps:
sanity graphql deploy --playground --debugOr set the environment variable:
SANITY_LOG_LEVEL=debug sanity graphql deployLook through your schema files (especially custom input components, preview components, and any imported utilities) for references to document, window, navigator, or other browser APIs
Check any third-party libraries you're importing in your schema - they might assume a browser environment
Since the deployment is working, you could technically leave it as-is, but fixing the root cause will clean up your deploy logs and prevent potential issues if Sanity changes how schema validation works in future versions.
If you're having trouble tracking down where the document reference is coming from, try temporarily removing custom components from your schema one by one until the error disappears - that'll help you isolate which file is causing it.
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