Loading...
Loading...
Error: Next.js 15 Async Request Context not found. This typically occurs when attempting to access headers() or cookies() outside of a request scope.In Next.js 15, the way Dynamic APIs like headers(), cookies(), and params are handled has shifted to a strictly asynchronous model. This error triggers when these utilities are called in a context where the request lifecycle is not active, such as in a globally executed utility function or a detached promise.
In Next.js 15, params and searchParams are now Promises. You must await them before use.
export default async function Page({ params }) {
const resolvedParams = await params;
const id = resolvedParams.id;
}Ensure headers() is only called inside the body of an async Server Component or Server Action.
Next.js 15 introduces a paradigm shift in how dynamic request data is accessed. In previous versions, headers() and cookies() were synchronous functions. In v15, they are transitioned to Request-Async Storage.
By making these APIs asynchronous, Next.js can better optimize the streaming lifecycle and enable features like Partial Prerendering (PPR). When you call an async request utility, Next.js can track that specific component as "dynamic" more accurately than with synchronous global hooks.
A common pitfall is calling these utilities inside a setTimeout or a non-awaited async function that outlives the request. Once the response is sent, the "Async Context" is destroyed by the V8 garbage collector to save memory. Any subsequent attempts to access that storage will throw this error.