Functions

draftMode

Async preview state. Enabling or disabling uses the bypass cookie in a supported mutation context. Preview state does not establish authorization. Source: https://nextjs.org/docs/app/api-reference/functions/draft-mode

Formal Syntax & Structure

nextjs syntaxnextjs
import { draftMode } from "next/headers"; const { isEnabled } = await draftMode();

Working Example

Example Snippetnextjs
import { draftMode } from "next/headers";export default async function PreviewStatus() {  const { isEnabled } = await draftMode();  return <main><h1>Preview status</h1><p>{isEnabled ? "Preview requested" : "Published mode"}</p></main>;}
Next.js Reference