Skip to content
Important
Security Advisory: React2Shell & two new vulnerabilities
Find out more
You are currently viewing documentation for version 13 of Next.js.

draftMode

Last updated August 24, 2023

The draftMode function allows you to detect Draft Mode inside a Server Component.

app/page.js
import { draftMode } from 'next/headers'
 
export default function Page() {
  const { isEnabled } = draftMode()
  return (
    <main>
      <h1>My Blog Post</h1>
      <p>Draft Mode is currently {isEnabled ? 'Enabled' : 'Disabled'}</p>
    </main>
  )
}

Version History

VersionChanges
v13.4.0draftMode introduced.

Was this helpful?

supported.