A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://rc.nextjs.org/docs/app/api-reference/functions/headers below:

Website Navigation


Functions: headers | Next.js

headers

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

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
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 Version Changes v15.0.0-RC headers is now an async function. A codemod is available. v13.0.0 headers introduced.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4