
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on your description, this is a common issue that usually comes down to a few specific causes. Here's how to troubleshoot:
The most common reason for this is related to your Sanity client configuration, specifically the API version and perspective settings. As of the recent API version v2025-02-19, Sanity changed the default perspective from raw to published.
When you test queries in Vision (Sanity Studio's query tool), it likely uses the raw perspective by default, which shows both draft and published documents. However, your client in Next.js might be using the published perspective, which only returns documents that have been published.
Look at where you're initializing your Sanity client and verify these settings:
import { createClient } from 'next-sanity'
export const client = createClient({
projectId: 'your-project-id',
dataset: 'production',
apiVersion: '2024-01-01', // Use a recent date
useCdn: false, // Set to false for getStaticProps
perspective: 'published', // This is likely your issue
})Double-check in Sanity Studio that your Events documents are actually published (not just saved as drafts). Look for the green "Published" indicator in the document.
raw PerspectiveTemporarily change your client configuration to use perspective: 'raw' to see if that returns your data. This will help confirm if the issue is perspective-related:
export const client = createClient({
// ... other config
perspective: 'raw',
})When using getStaticProps, set useCdn: false in your client configuration. The CDN can cache empty results during development:
useCdn: false, // Important for getStaticPropsMake sure your GROQ query in getStaticProps matches what you're testing in Vision:
export async function getStaticProps() {
const events = await client.fetch(`*[_type == "events"]`)
console.log('Events:', events) // Add logging to debug
return {
props: {
events
}
}
}getStaticProps to see what's actually being returnedIf you're using the next-sanity toolkit, make sure you've properly configured it during setup, as it handles a lot of this configuration automatically.
The perspective issue is by far the most common culprit for this "works in Studio, empty in Next.js" problem, so start there!
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