← 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

How to fix it

  1. Mark the route as dynamic:

    // app/dashboard/page.tsx
    export const dynamic = 'force-dynamic';
  2. 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

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

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy