rembrembdocs

headers

Last updated April 23, 2026

headers is an async function that allows you to read the HTTP incoming request headers from a Server Component.

app/page.tsx

JavaScriptTypeScript

import { headers } from 'next/headers'
 
export default async function Page() {
  const headersList = await headers()
  const userAgent = headersList.get('user-agent')
}

Reference

Parameters

headers does not take any parameters.

Returns

headers returns a read-only Web Headers object.

Good to know

Examples

Using the Authorization header

app/page.js

import { headers } from 'next/headers'
 
export default async function Page() {
  const authorization = (await headers()).get('authorization')
  const res = await fetch('...', {
    headers: { authorization }, // Forward the authorization header
  })
  const user = await res.json()
 
  return <h1>{user.name}</h1>
}

Version History

VersionChanges
v15.0.0-RCheaders is now an async function. A codemod is available.
v13.0.0headers introduced.

Was this helpful?