Dynamic server usage ⚛️ React

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).

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 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.