Next.js Error DYNAMIC_SERVER_USAGE: Dynamic server usage
During next build a route marked static (or force-static) called a dynamic API — cookies(), headers(), searchParams or no-store fetch. Mark the route dynamic, or stop swallowing the internal error in try/catch.
Identify: does your log match?
Error: Dynamic server usage: Route /dashboard couldn't be rendered statically because it used `cookies`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
at u (/app/.next/server/chunks/731.js:1:39518)
at Object.get (/app/.next/server/chunks/731.js:1:37862) {
description: "Route /dashboard couldn't be rendered statically because it used `cookies`.",
digest: 'DYNAMIC_SERVER_USAGE'
}- High
try/catch swallows the bailout
Next.js signals dynamic usage by throwing; a try/catch around cookies() or fetch catches it, so the build cannot switch the route to dynamic.
- Medium
Forced static rendering
export const dynamic = 'force-static' or 'error', or generateStaticParams, conflicts with reading request data.
- Medium
Uncached fetch in a static route
fetch(url, { cache: 'no-store' }) or revalidate: 0 inside a page expected to prerender.
Fix
Rethrow Next.js internal errors from try/catch
export default async function Page() { try { const session = (await cookies()).get('session')?.value; return <Dashboard session={session} />; } catch (e) { return <p>Something went wrong</p>; } }
import { cookies } from 'next/headers'; import { unstable_rethrow } from 'next/navigation'; export default async function Page() { try { const session = (await cookies()).get('session')?.value; return <Dashboard session={session} />; } catch (e) { unstable_rethrow(e); // lets DYNAMIC_SERVER_USAGE, redirect(), notFound() propagate return <p>Something went wrong</p>; } }
unstable_rethrow re-throws errors Next.js uses for control flow, so the route is correctly marked dynamic.
Verify: reproduce it on purpose
$ printf "import {cookies} from 'next/headers';export const dynamic='error';export default async function P(){(await cookies()).get('a');return null}\n" > app/page.tsx && npx next buildRun it against a dev environment to trigger DYNAMIC_SERVER_USAGE on purpose and test your error handler.
Prevent
- Keep cookies()/headers() calls outside try/catch.
- Check the build output: ƒ = dynamic, ○ = static.
- Move request-specific UI into a small dynamic component.
FAQ
Why does it only fail in next build, not next dev?
Dev renders every request dynamically. Static prerendering, and therefore this error, only happens at build time.
Is this error harmful in logs at runtime?
If you see it at runtime, an error boundary or try/catch swallowed it. It is a build-time signal, not a user-facing error.
Do I need force-dynamic if I call cookies()?
No. Calling cookies() opts the route into dynamic rendering automatically, unless you forced static or caught the error.
Related errors
Last verified 2026-10-21 · Source: Next.js /errors directory (vercel/next.js) · Official docs ↗ · ~9,900 searches/mo