
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on your code, I can see a few potential issues. The most likely culprit is that you're querying for published documents, but your content might only exist as drafts in Sanity Studio.
When you create documents in Sanity Studio, they initially exist as draft documents with IDs prefixed by drafts.. Your query *[_type == "product"] by default only returns published documents (without the drafts. prefix). If you haven't explicitly published your documents, they won't show up in your query results.
To fix this, you have a few options:
Go to your Sanity Studio, open each product and banner document, and click the "Publish" button. This will create published versions that your query can find.
previewDrafts perspectiveModify your client configuration to include drafts:
export const client = sanityClient({
projectId: '********',
dataset: 'production',
apiVersion: '2022-05-08',
useCdn: true,
token: process.env.NEXT_PUBLIC_SANITY_TOKEN,
perspective: 'previewDrafts', // This will show drafts with published fallback
});The previewDrafts perspective prioritizes draft documents over published versions, which is perfect for development.
You can modify your query to exclude draft IDs:
const query = '*[_type == "product" && !(_id in path("drafts.**"))]';Or score drafts higher to prioritize them:
const query = '*[_type == "product"] | score(_id in path("drafts.**")) | order(_score desc)';Your token is stored in process.env.NEXT_PUBLIC_SANITY_TOKEN. The NEXT_PUBLIC_ prefix makes it available on the client-side, which is fine for read operations. However, make sure:
.env.local fileSince you're using useCdn: true with a token, be aware that CDN caching and tokens can sometimes conflict. For development, try setting useCdn: false to rule out caching issues.
Your schema.js is using the old Studio v2 syntax (part:@sanity/base/schema-creator). If you're following an old tutorial, this might work, but be aware that newer tutorials use Studio v3 syntax.
https://yourstudio.sanity.studio/desk and verify your products and banners are theredrafts., they're unpublishedconsole.log(client.config()) to verify your configuration is correctThe most common fix is adding perspective: 'previewDrafts' to your client config or publishing your documents in Studio. Let me know if that resolves 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