Dynamic server usage React Origin: On your device Last updated 12 Oct 2026

Error: Dynamic server usage: Route /x couldn't be rendered statically because it used `cookies`

Next.js tried to statically render a route that reads request-specific data (cookies, headers, searchParams).

Exact message you may see Dynamic server usagecouldn't be rendered statically because it used
Seen on: React

Meaning

During next build, routes are prerendered by default. Using cookies(), headers() or uncached fetches forces dynamic rendering; Next.js reports it when it can’t render statically.

Common causes

  • cookies()/headers() in a page meant to be static
  • fetch with cache: 'no-store' in a static route
  • Catching the dynamic usage error in try/catch

⚡ Quick fix

  1. Mark the route dynamic: export const dynamic = 'force-dynamic'
  2. Move request-specific logic to client components or route handlers
  3. Don’t swallow Next.js internal errors in try/catch

Detailed fix by platform

React

  1. export const dynamic = 'force-dynamic';

How to diagnose

  1. Route — Which route and API?
  2. Intent — Should it be static?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

async Client Component — Error: async/await is not yet supported in Client Components, only Server Components. (React)async Client ComponentCan't resolve 'fs' — Module not found: Can't resolve 'fs' (Next.js / webpack 5) (React)Can't resolve 'fs'cookies() should be awaited — Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value (Next.js)cookies() should be a…Element type is invalid — Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined (React)Element type is inval…Functions cannot be passed — Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". (React)Functions cannot be p…Functions not valid as child — Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. (React)Functions not valid a…Hydration failed — Error: Hydration failed because the initial UI does not match what was rendered on the server (React)Hydration failedneeds useState — You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client" (React)needs useStateDynamic s…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.