SOLVED: Preview setup wrong in referenced type
Great to hear you solved it! For anyone else who stumbles upon this thread with similar issues, it sounds like the problem was related to preview configuration in a referenced document type.
This is a common gotcha in Sanity schemas. When you're working with references and trying to display them in the Studio (like in arrays, reference inputs, or search results), each referenced document type needs its own preview configuration defined in its schema.
A typical fix looks like this:
export default {
name: 'author',
type: 'document',
fields: [
{name: 'name', type: 'string'},
{name: 'image', type: 'image'},
],
preview: {
select: {
title: 'name',
media: 'image'
}
}
}Common issues that cause preview problems:
- Missing
previewobject entirely on the referenced type - Incorrect field paths in the
selectobject - Typos in field names (which you already checked!)
- Using
prepare()function with incorrect return values
If you're still learning about previews, the Sanity documentation on previews covers all the details about select, prepare, and how to customize what shows up in the Studio UI.
Thanks for updating the thread with your solution - this kind of post helps the community a lot! 🙌
Show original thread3 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.