The Error
During next build (or in production logs), you see something like:
Error: Dynamic server usage: Route /dashboard couldn't be rendered statically
because it used `cookies`.or the same message mentioning headers, searchParams or no-store fetches.
Next.js tries to pre-render pages at build time when it can. This error means Next.js tried to render a route statically, but the code needs something that only exists at request time, like the user's cookies.
🎯 Quick Fix
Decide what the page should be:
- Personalised per request (uses cookies, headers, the logged-in user)? Make it dynamic:
// app/dashboard/page.tsx
export const dynamic = "force-dynamic";- Same for everyone? Remove the request-time API from the static path (move it into a client component, a route handler, or a smaller dynamic part).
Why It Happens
rendered once, for everyone?"} T -->|"Yes: no cookies/headers,
cacheable data"| S["Static page
(fast, cached)"] T -->|"Uses cookies(), headers(),
searchParams, uncached fetch"| D["Must render per request"] D --> E{"Marked dynamic
or opted out of static?"} E -->|No| ERR["❌ Dynamic server usage error"] E -->|Yes| OK["✅ Rendered on each request"]
APIs that make a route dynamic include:
cookies()andheaders()fromnext/headerssearchParamsin a pagefetch(..., { cache: "no-store" })and some uncached data accessconnection()and other request-time APIs
Fixes
1. Mark the Route as Dynamic
For pages that genuinely depend on the request (dashboards, account pages):
export const dynamic = "force-dynamic";2. Keep Most of the Page Static
Move the personalised piece into its own component and stream it in with Suspense, so the rest of the page can still be prerendered:
import { Suspense } from "react";
import { cookies } from "next/headers";
async function Greeting() {
const name = (await cookies()).get("name")?.value ?? "there";
return Hi, {name}
;
}
export default function Page() {
return (
<>
Pricing
{/* static */}
…}>
{/* request-time */}
>
);
}With Next.js's newer Cache Components / Partial Prerendering model, this pattern lets static shells and dynamic parts mix on one page.
3. Cache Data Instead of Fetching Per Request
If the data is the same for all users, cache it and revalidate on a schedule:
const res = await fetch("https://api.example.com/plans", { next: { revalidate: 3600 } });4. Don't Read Cookies Where You Don't Need To
A common accident: a shared layout or helper reads cookies() for auth, making every page dynamic. Read auth only where it's needed, or isolate it in a Suspense-wrapped component.
Don't Swallow the Error
If you wrap cookies() in try/catch, you can accidentally hide the signal Next.js uses to detect dynamic rendering. Let it throw, or check process.env and route config instead of catching framework errors.
Checklist
- Find which API triggered it (the message names it:
cookies,headers,searchParams...) - Decide: static, dynamic, or mixed with Suspense
- Add
export const dynamic = "force-dynamic"for truly per-request pages - Cache shared data with
revalidate - Remove request-time reads from shared layouts where possible
Frequently Asked Questions
What does "Dynamic server usage" mean in Next.js?
It means Next.js tried to render a route statically at build time, but the code used a request-time API such as cookies(), headers() or searchParams. The route must either be rendered dynamically per request or have that request-time code removed from the static path.
Is export const dynamic = "force-dynamic" bad for performance?
It renders the page on every request, which is slower and costs more than serving a cached static page. It's correct for personalised pages like dashboards. For mostly static pages, keep the page static and isolate personalised parts with Suspense or client components.
Why does cookies() make my whole site dynamic?
If a shared layout or helper used on every page calls cookies(), every route depending on it must render per request. Move the cookie read into the specific pages or components that need it, ideally wrapped in Suspense.
Conclusion
The "Dynamic server usage" error means a route marked for static rendering used request-time data. Decide whether the page is personalised: mark truly per-request pages dynamic, cache shared data with revalidation, and isolate personalised parts so the rest of the page stays fast and static.
Sources
- Next.js docs: Dynamic server error
- Next.js docs: Route segment config (dynamic)
- Next.js docs: cookies
Last verified: 2 November 2026.
Related reads: Fix Next.js Hydration Error · Next.js Server Actions Tutorial · Supabase Auth With Next.js App Router · Caching Strategies Explained
I write practical guides for developers. Follow on LinkedIn or X, or invite me to speak.