← All errors · Next.jsNext.js App Router & config errors
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.
Prevent this next time
- Run `next build` (not just `next dev`) before every deploy; several of these errors only appear in production builds.
- Keep a checked-in `.env.example` listing every required variable.
FAQ
What does "Dynamic server usage: Route couldn't be rendered statically" mean?
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.
What usually causes it?
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 do I fix it?
1. Mark the route as dynamic: 2. 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