headers()
The async function from next/headers that returns the incoming request's HTTP headers for reading in Server Components.
In more detail
Calling it makes the route dynamic. In Next.js 15 it must be awaited. The returned headers are read-only.
Related terms
- cookies() — The async function from next/headers that reads the request's cookies, and in Server Actions or Route Handlers can also set or delete them.
- HTTP header — A named line of metadata in an HTTP message, such as Content-Type: application/json, that describes the body, the caller or how to handle the exchange.
- Dynamic APIs — Functions and props that depend on the incoming request, such as cookies(), headers() and searchParams, which make a route dynamic.
Taught in
- Full Route Cache: Static Rendering & Segment Config — Next.js 15 & Modern App Router Architecture
- Session Management: Secure Cookies & Token Validation — Next.js 15 & Modern App Router Architecture