Keeping it static starts with knowing the usual causes: cookies() or headers() in a layout (auth state, theme, locale), awaited searchParams, unlisted params, and uncached data. Then:
- per-user UI (a "Hi, name" header) moves to the client, or with Cache Components behind
<Suspense>so only that part renders per request; - variants that live in the URL get a segment and
generateStaticParams(/[locale]/pricing); - shared data gets a cache:
fetchwithcache: 'force-cache'ornext.revalidatewithout Cache Components,use cachewith them.
Guarding it turns a regression into a failed build:
- Without Cache Components,
export const dynamic = 'error'. In 16.4.5 a page whose header read cookies failed withRoute /err-cookies with `dynamic = "error"` couldn't be rendered statically because it used `cookies()`; ano-storefetch was reported as`revalidate: 0 fetch <url>`. - With Cache Components,
export const ensureStatic = 'navigation'(stable since 16.4.0) on a page or layout. It requires the whole server-rendered route to prerender, so request data fails the build even inside<Suspense>.'shell'and'prefetch'cover only the prefetch stages. WithoutcacheComponentsthe export itself fails the build.
Finding the cause: the route table says that a route is dynamic (ƒ, or ◐ with Cache Components), and the next dev indicator menu says Route Dynamic, but neither says why. The guard errors name the API. Without Cache Components that's all you get, so search for the call, layouts included. With them, the build stack for a runtime read can be component names only (at Suspense (<anonymous>)); next build --debug-prerender disables server minification and enables source maps, which gave the exact line.