Content appears in preview then disappears after page loads

23 replies
Last updated: Dec 1, 2025
A completely unrelated question to my last one, but can anyone understand why my content is appearing in the preview and then promptly disappearing when the page finishes loading? Video here: https://www.dropbox.com/s/js2vxz0fpfnixjz/Screen%20Recording%202022-01-13%20at%2010.05.11.mov?dl=0
AI Update

Based on the video you shared, this looks like a classic issue where content loads initially and then disappears after the page finishes loading. This was a common problem with older Next.js preview implementations from around 2022.

Important note: The preview approach you're likely using (usePreviewSubscription from older versions of next-sanity) has been replaced with modern alternatives. The current recommended approaches for previewing draft content in Next.js are:

  1. Visual Editing with Draft Mode - The modern approach that provides live-as-you-type updates with clickable overlays
  2. Live Content API - For real-time content delivery without complex preview setup

However, if you're still working with the older usePreviewSubscription pattern, the most common cause of content disappearing is:

Parameter name mismatches - Your GROQ query expects a variable name (like $slug) but your subscription hook is passing a different parameter name. When the subscription takes over from the initial getStaticProps data, it runs the query with incorrect parameters and returns null.

For example, if your query is:

*[_type == "page" && slug.current == $slug][0]

Your subscription params must use slug:

const { data: page } = usePreviewSubscription(pageQuery, {
  params: { slug: data?.page?.slug }, // Must match $slug in query
  initialData: data.page,
  enabled: preview,
});

Other common causes from that era:

  • Initial data structure mismatch - Passing the wrong shape to initialData
  • Missing or incorrect authentication token for fetching draft content
  • Browser blocking third-party cookies if Studio and frontend are on different domains

My recommendation: If you're starting fresh or can refactor, migrate to the modern Draft Mode with Visual Editing approach. It's more reliable, better maintained, and provides a superior editing experience with live updates as you type. The old usePreviewSubscription pattern had various quirks that have been solved in the current implementation.

Show original thread
23 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.

Was this answer helpful?