How it works
When Draft Mode is enabled, Next.js sets a__prerender_bypass cookie. Subsequent requests containing this cookie render pages dynamically at request time instead of serving cached static output.
Setup
Create a draft Route Handler
Create a Route Handler that enables Draft Mode:Visit
/api/draft to test—check the browser’s DevTools for the Set-Cookie response header with __prerender_bypass.Secure the Route Handler with a secret token
In production, secure your draft URL with a secret token shared between your Next.js app and your headless CMS:Configure your CMS to use a draft URL like:
Disabling draft mode
Create an endpoint to disable draft mode:Checking draft mode status
You can read the draft mode status in any Server Component:Draft Mode is incompatible with static exports since it requires dynamic rendering per request.
