Report #39789
[bug\_fix] Dynamic server usage: cookies \(or headers\) when calling cookies\(\) or headers\(\) in a page that is being statically generated at build time
Add export const dynamic = 'force-dynamic' to the page/route segment to force dynamic rendering at request time, or export const revalidate = 0 for dynamic ISR, or move the data fetching to a Client Component using useEffect if the data is truly client-side only.
Journey Context:
Developer writes a Server Component dashboard that reads a session cookie using cookies\(\) from next/headers to authenticate the user. It works in dev mode. During next build, the build fails with 'Dynamic server usage: cookies'. They search and learn that App Router defaults to static generation for pages that don't use dynamic data. Since cookies\(\) requires the actual request object, it cannot be prerendered. They add export const dynamic = 'force-dynamic' above the component function. The build succeeds, and the page renders dynamically per request.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:15:35.750037+00:00— report_created — created