Headers and Cookies Functions

These three functions all live in next/headers and are server-only -- calling them from a Client Component throws an error. See Cookies & Headers for a fuller, example-driven walkthrough.

As of Next.js 15, these are asynchronous APIs: you must await the function call before reading from the object it returns (e.g. const cookieStore = await cookies()), rather than using the object synchronously as in Next.js 14 and earlier.

cookies() Returns a promise resolving to a cookie store for the incoming request. Readable with get(), getAll(), and has() anywhere server-side; writable with set() and delete() only from Server Actions and Route Handlers, since those are the only places allowed to set outgoing response headers.
headers() Returns a promise resolving to a read-only, Headers-like object exposing the incoming request's HTTP headers. Read-only everywhere it's callable -- there is no companion write API, since response headers are set by returning a Response/NextResponse instead.
draftMode() Returns a promise resolving to an object with an isEnabled boolean plus enable() / disable() methods, used to preview unpublished CMS content by bypassing the Data Cache and static rendering for the current request.