Fix guides / Next.js: "Dynamic server usage: couldn't be rendered statically"
How to fix Next.js "Dynamic server usage ... couldn't be rendered statically"
Your build log says Error: Dynamic server usage: Route /dashboard couldn't be rendered statically because it used cookies (or headers, or nextUrl.searchParams). Next.js tried to build this page as static HTML at build time, and something in it only exists during a real request.
Why it happens
The App Router prerenders routes at build time when it can. Reading cookies(), headers(), or request search params makes a route dynamic. Usually Next.js detects this and switches automatically. The error appears when the detection is defeated, most often because the call is wrapped in a try/catch that swallows the signal, or the route also sets export const dynamic = 'force-static' or generateStaticParams without allowing dynamic rendering. Auth helpers that read cookies, such as a Supabase server client, are the most common trigger.
Fix 1: mark the route as dynamic
// app/dashboard/page.tsx (or layout.tsx, or route.ts) export const dynamic = 'force-dynamic';
This is the right answer for pages that depend on who is logged in.
Fix 2: do not catch the dynamic signal
If you wrap cookies() or a function that calls it in try/catch, rethrow errors you did not expect, or move the call outside the try block. Next.js uses a thrown signal to detect dynamic usage during build.
Fix 3: keep the page static and move the dynamic part
If most of the page is marketing content, keep it static and load the user-specific bit in a client component, or wrap it in <Suspense> so only that piece renders per request.
Fix 4: route handlers
For app/api/.../route.ts, a GET handler that reads request.headers or cookies should also export dynamic = 'force-dynamic' if the build complains.
Check the fix
- Run
npm run buildlocally. In the route table at the end, the page should show as dynamic (the ƒ symbol) with no error. - Deploy and confirm logged-in content loads for the right user.
Quick Fix, $49Full Rescue, $149Ask first
Last updated 2026-10-19.