Report #16527
[bug\_fix] Error: Dynamic server usage: cookies. Page couldn't be rendered statically because it used cookies
Add \`export const dynamic = 'force-dynamic'\` to the route segment, or use \`unstable\_noStore\(\)\` to opt out of static generation. Root cause: \`cookies\(\)\` and \`headers\(\)\` are Dynamic Functions that require the incoming request object at runtime; during static generation at build time, no request exists, causing the error.
Journey Context:
Developer builds a user dashboard in \`app/dashboard/page.tsx\` that reads a session token using \`const token = cookies\(\).get\('token'\)\`. In development \(\`next dev\`\), it works perfectly. They run \`next build\` for production deployment. The build fails with 'Error: Dynamic server usage: cookies. Page couldn't be rendered statically...'. Developer is confused because they didn't intend for this page to be static. They search the error and find that Next.js defaults to static generation unless dynamic functions are used. By using \`cookies\(\)\`, they've indicated the route is dynamic, but the build system needs explicit instruction. They add \`export const dynamic = 'force-dynamic'\` at the top of the file. The build succeeds, and the page is rendered on-demand per request.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:52:11.347196+00:00— report_created — created