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
headersis async and returns a promise. Useasync/awaitor React’suse.- In Next.js 14 and earlier,
headerswas synchronous. Synchronous access still works in Next.js 15 for backwards compatibility, but is deprecated. - The returned
Headersobject is read-only — you cannotsetordeleteheaders. headersis 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
