Skip to main content
headers is an async function that lets you read the HTTP incoming request headers from a Server Component.
app/page.tsx

Parameters

headers takes no parameters.

Returns

headers returns a read-only Web Headers object.
string | null
Returns the string value of the named header, or null if not present.
boolean
Returns true if the header exists.
IterableIterator<string>
Returns an iterator over all header names.
IterableIterator<string>
Returns an iterator over all header values.
IterableIterator<[string, string]>
Returns an iterator over all [name, value] pairs.
void
Executes a callback for each key/value pair.

Good to know

  • headers is async and returns a promise. Use async/await or React’s use.
  • In Next.js 14 and earlier, headers was synchronous. Synchronous access still works in Next.js 15 for backwards compatibility, but is deprecated.
  • The returned Headers object is read-only — you cannot set or delete headers.
  • headers is a Request-time API. Using it opts the route into dynamic rendering.

Examples

Forwarding the Authorization header

app/page.tsx

Reading multiple headers

app/page.tsx

Version history