Next.js 15: headers() should be awaited before using its value
Error: Route "/api/user" used `headers()`. `headers()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
Immediate Remediation
tsx
const headerList = await headers();
const token = headerList.get('authorization');Root Cause Analysis
In Next.js 15, headers() is an asynchronous API that returns a Promise. Accessing its methods synchronously without awaiting triggers a runtime error because the underlying dynamic API can only be read after the promise resolves.
Verification & Guardrails
- Requires Next.js 15 or later; in earlier versions headers() was synchronous.
- Make sure the containing function is marked async before awaiting.
- Run `next build` to confirm no remaining sync dynamic API warnings.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.