← All fixes
Next.js: Dynamic server usage: Route couldn't be rendered statically because it used cookies
#115Error
Error: Dynamic server usage: Route /dashboard couldn't be rendered statically because it used `cookies`.
Why it happens, and why this works
Next tried to pre-render the route at build time, but it reads per-request data (cookies(), headers(), searchParams, an uncached fetch). Often this happens inside a try/catch that swallows Next's internal signal, or with export const dynamic = 'force-static'.
Fix
If the page is per-user, let it be dynamic: remove any force-static setting and don't wrap cookies()/headers() calls in try/catch that hides the error (or rethrow it). You can declare it explicitly with export const dynamic = 'force-dynamic'. If it should be static, move the cookie reading into a client component or middleware.
Did it work?
No reports yet0 worked0 didn't
Tried it yourself?
Related fixes
ReferenceError: window is not defined / document is not defined in Next.js (server render)
#137ReferenceError: window is not defined (or document / localStorage / navigator is not defined) during next build or on page load
nextjsreactjavascriptNo reports yet
React: Too many re-renders. React limits the number of renders to prevent an infinite loop
#116Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
reactNo reports yet
fetch('/api/...') on the server: Failed to parse URL
#34TypeError: Failed to parse URL from /api/users (Invalid URL) when calling fetch in Node, SSR or a server component