← All errors · Next.js
Dynamic server usage: Route couldn't be rendered statically
Exact error
Error: Dynamic server usage: Route /dashboard couldn't be rendered statically because it used `cookies`.
What it means
During build Next.js tried to prerender a route statically, but the route reads request-time data (cookies(), headers(), searchParams), which is only available per request.
Likely causes
- Calling cookies() or headers() in a page or layout that Next.js assumes is static.
- Using output: "export" (static export) together with request-time APIs.
How to fix it
Mark the route as dynamic:
// app/dashboard/page.tsx export const dynamic = 'force-dynamic';If you use static export, you cannot use cookies()/headers(). Move that logic to the client or to an external API.
Related errors
- You're importing a component that needs useState. It only works in a Client Component
- Command "npm run build" exited with 1
Get new fixes weekly
No spam. Unsubscribe anytime. Privacy