Easy method to display all documents with references to a certain document.
Yes! There's a great way to display documents that reference a specific document in Sanity Studio. Sanity's Content Lake indexes references bi-directionally, which means you can query "incoming references" - documents that contain references to the current document.
The Easy Method: Documents Pane Plugin
The simplest approach is to use the Documents Pane plugin. This plugin lets you display GROQ query results directly in your Studio's view pane, which is perfect for showing which pages use a specific widget.
Installation
sanity install documents-paneSetup
In your Structure Builder configuration (typically deskStructure.js), add this to your widget document views:
import DocumentsPane from 'sanity-plugin-documents-pane'
S.view
.component(DocumentsPane)
.options({
query: `*[!(_id in path("drafts.**")) && references($id)]`,
params: { id: `_id` },
useDraft: false
})
.title('Referenced By')This configuration:
query: Finds all documents (excluding drafts) that reference the current document's IDparams: Passes the current document's_idas a parameteruseDraft: Set tofalseto only show published documents
When editors open a widget in Studio, they'll see a "Referenced By" tab showing all the pages that use that widget. They can click through to those pages directly from the widget's edit view.
How It Works
As explained in the Connected Content docs, references in Sanity are always bi-directional. When a page references a widget, the Content Lake automatically indexes this relationship in both directions. This means you can query:
- From the page to find what widgets it uses
- From the widget to find what pages reference it (incoming references)
Alternative: Custom GROQ Query
If you need more control or want to display this information elsewhere, you can use the references() function in GROQ directly:
*[_type == "page" && references("widget-id-here")]The Documents Pane plugin is the easiest solution since it provides a ready-made UI component that integrates seamlessly into your Studio's document editing experience. It's exactly designed for this "show me what references this" use case!
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.