Lorixen.
EN

Draft previews in a headless CMS: see it before it's live

Short answer: With a headless CMS, editors write in one system and the website is built by another, so the CMS's "Preview" button doesn't work out of the box. You set it up: the CMS opens a special preview URL on your site with a secret token, your site checks it, switches that browser into a draft mode that fetches unpublished content and skips caches, and shows a clear "Preview" banner with an exit link. Everyone else keeps seeing the published, cached site.

Why editors lose preview when you go headless

In a traditional CMS, the editing screen and the website are the same application, so preview is built in. A headless setup splits them: content lives in the CMS and is delivered through an API, while the website is a separate front end, often pre-rendered or heavily cached for speed.

That split is great for performance and flexibility, but it creates a gap for marketing teams. They write a landing page, press Preview and see nothing, an error, or yesterday's published version. Some resort to publishing pages with hidden URLs to check them, which risks unfinished content being found or indexed.

How draft preview works

Most headless CMS and framework combinations follow the same pattern. Next.js's Draft Mode guide is a clear example:

  1. The CMS opens a preview link such as /api/draft?secret=…&slug=/offers/winter-sale in a new tab when the editor clicks Preview. The secret is a shared token known only to the CMS and your site.
  2. Your site validates the secret and the slug, then enables draft mode for that browser. In Next.js, draftMode().enable() sets a bypass cookie.
  3. It redirects to the page. Because the cookie is present, the page is rendered on demand instead of served from the pre-rendered cache.
  4. Data fetching asks for drafts. Your code checks whether draft mode is on and, if so, requests unpublished content from the CMS, usually with a separate preview API token.

The Next.js documentation notes that in draft mode, cached or pre-rendered content is bypassed and fetched from upstream sources directly, while other visitors continue to see the cached version, and that the page is served with no-store cache headers.

Other frameworks and CMS platforms have equivalent features under names like preview mode, draft mode or visual editing. The concepts carry over.

Secure the preview route

A preview link that anyone can use exposes unreleased content: prices before a sale, a product before launch, a job advert before approval. Protect it:

  • Use a long, random secret, stored as an environment variable on both sides, never in front-end code.
  • Validate the slug against content that exists in the CMS, and only redirect to paths on your own site, so the route can't be used as an open redirect.
  • Keep the preview API token server-side. The token that can read drafts should never reach the browser.
  • Rotate the secret if it's ever shared outside the CMS.

Make it obvious when someone is previewing

Editors forget they're in preview, then panic when "the live site" shows unapproved text. Add:

  • A fixed banner such as "Preview mode: you're seeing unpublished content", with the date and time.
  • An "Exit preview" button that clears the cookie. Next.js offers draftMode().disable() for this.
  • Optional extras like the content's status and who last edited it.

Keep preview out of search and analytics

Preview pages shouldn't be indexed or counted as real traffic:

  • Send noindex on draft-mode responses.
  • Skip analytics, or tag preview visits so they're filtered out.
  • Make sure the CDN doesn't cache draft responses. Draft mode in many frameworks already sends no-store headers; verify your CDN respects them.

Preview the whole page, not just one block

Editors need to see content in context: navigation, related products, the footer and the real layout. Make sure every data fetch on the page honours draft mode, including:

  • Shared components, like menus or banners, that pull from the CMS.
  • References to other entries, such as a featured product that's also unpublished.
  • Images and media uploaded but not yet published.

Test a draft page that references other draft content; it's the case most often missed.

Consider live preview

Many headless CMS platforms now offer live or visual preview, where the site appears inside the editor and updates as the editor types, sometimes with click-to-edit overlays. Sanity's Presentation tool documentation, for example, covers implementing draft mode alongside live preview updates and overlays. It takes more setup, but for teams publishing landing pages daily it saves a lot of back and forth. Start with basic draft preview and add live preview once that's solid.

Test the workflow with editors

Before launch, have real editors try:

  1. Create a new page and preview it before publishing.
  2. Edit a published page and preview the change while the live version stays unchanged.
  3. Share a preview with a colleague, if your setup allows sharing links.
  4. Exit preview and confirm they see the live site.

Their feedback often reveals missing pieces, like a component that ignores draft content.

A worked example

Picture a hypothetical San Diego surf-school chain that moved its website to a headless CMS and a pre-rendered front end. Pages loaded quickly, but the marketing team couldn't preview seasonal offer pages, so they published them under hidden URLs, one of which appeared in search results. The developer added a secret-protected preview route that enabled draft mode, fetched drafts with a server-side preview token, sent noindex on preview responses and added a banner with an exit button. Editors now preview offers before they go live.

FAQ

Can I just use a staging site for previews?

You can, but staging often lags behind production content and needs separate deploys. Draft preview shows drafts on the real site design.

Does draft mode slow down my site?

Only for people in draft mode, whose pages are rendered on demand. Public visitors still get cached pages.

Can I preview scheduled content?

Yes, if your CMS returns scheduled entries as drafts until their publish time. Check how yours handles scheduling.

If your editors can't see changes before they go live, tell us about your CMS and front end.

Sources

WhatsAppBook a call