
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, the Presentation tool's "Documents on this page" feature should work in cross-origin setups like yours (Studio on :3333, Next.js on :3000). The key is proper configuration and understanding how the system detects documents.
Here's what you need to ensure is set up:
sanity.config.ts):Make sure you've configured allowOrigins in the Presentation tool config:
presentationTool({
previewUrl: {
initial: 'http://localhost:3000',
previewMode: {
enable: '/api/draft-mode/enable',
disable: '/api/draft-mode/disable',
},
},
allowOrigins: ['http://localhost:*'], // This allows any localhost port
})The "Documents on this page" sidebar is populated through stega-encoded Content Source Maps that are embedded in your server-rendered HTML. This means:
Server-side fetching with stega is sufficient - You don't need client-side loaders for the basic "Documents on this page" functionality to work. The Studio reads the stega-encoded metadata from your rendered DOM.
Make sure you're fetching with stega encoding enabled in your draft mode:
import { client } from '@/sanity/lib/client'
// In your draft mode pages
const data = await client.fetch(query, params, {
perspective: 'previewDrafts',
stega: true, // This enables stega encoding
// or use resultSourceMap: true for the raw source maps
})import { VisualEditing } from '@sanity/visual-editing'
// In your layout or page when draft mode is active
{draftMode().isEnabled && <VisualEditing />}Since clicking from Structure → Presentation works but loading Presentation directly doesn't show documents, check:
CORS settings: Ensure http://localhost:3000 is in your project's CORS origins (manage.sanity.io → API settings)
Draft mode activation: When you load Presentation directly, is your Next.js app actually entering draft mode? The Presentation tool should be calling your /api/draft-mode/enable endpoint.
Stega encoding: Verify stega is enabled in your data fetching. You can inspect the DOM and look for invisible Unicode characters appended to text content (these contain the document references).
The system works cross-origin by reading the stega-encoded metadata directly from your rendered HTML - no postMessage communication is required for basic "Documents on this page" functionality. Client-side loaders (like useQuery) are only needed for enhanced features like near-instant refresh rates and drag-and-drop page building.
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