
On this page
This site runs on Next.js 16 with cacheComponents: true. It has a blog, case studies, a projects page and a contact form, and all its content is static. Turning Cache Components on looked like a one-line change. It wasn't: the build failed on a footer, a config export stopped being allowed, and unknown blog URLs started returning 200.
Below is each problem in the order I hit it, why Next.js behaves that way, and the code from this site that fixed it. If you are planning the same migration, this is the list I wish I'd had.
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
cacheComponents: true,
partialPrefetching: true,
reactCompiler: true,
};
export default nextConfig;What Cache Components changes
With Cache Components on, Next.js prerenders a static shell for every route and expects you to be explicit about anything that can't be part of it. The old route segment configs (dynamic, revalidate, fetchCache) are replaced by the "use cache" directive and cacheLife(). Data that is the same on every run (imports, pure computation) is prerendered automatically. Values that change between runs (the current time, random numbers) or depend on the request must either be cached or rendered at request time inside <Suspense>.
That rule is behind almost every error below.
1. new Date() in the footer broke the build
The footer prints the current year next to the copyright, and the obvious code for that is new Date().getFullYear(). With Cache Components on, new Date(), Date.now(), Math.random() and crypto.randomUUID() during prerendering are errors, because the result would be frozen into the static HTML without you saying so.
There are two fixes. If the value must be fresh on every request, call await connection() first and wrap the component in <Suspense>. For a copyright year that is far too much: it changes once a year. So I cached it instead, and told Next.js to recompute it at most once a day:
import { cacheLife } from "next/cache";
export async function CurrentYear() {
"use cache";
cacheLife("days");
return <>{new Date().getFullYear()}</>;
}The footer stays part of the static page, and on 1 January it rolls over to the new year without a redeploy.
2. dynamicParams is gone
Blog posts and case studies live at /blog/[slug] and /case-studies/[slug]. The usual pattern was generateStaticParams() plus export const dynamicParams = false to turn unknown slugs into 404s. With Cache Components the build stops with:
Route segment config "dynamicParams" is not compatible with `nextConfig.cacheComponents`.The replacement is to delete the export and check the slug yourself. Slugs from generateStaticParams() are prerendered at build time; any other slug is rendered on request, so the page has to call notFound() when the post doesn't exist:
export function generateStaticParams() {
return getAllPosts().map((post) => ({ slug: post.slug }));
}
export default async function BlogPostPage({ params }: PageProps<"/blog/[slug]">) {
const { slug } = await params;
const post = getPostBySlug(slug);
if (!post) notFound();
// ...render the post
}PageProps<"/blog/[slug]"> is a global type that Next.js generates for every route, so params is typed without writing the interface by hand. After adding a new route, run npx next typegen (or start the dev server) to refresh it.
3. notFound() returned 200 instead of 404
This one looked like a bug. /some-random-url returned a proper 404, but /blog/a-post-that-does-not-exist showed the 404 page with status 200.
It is documented behaviour. The website layout has a loading.tsx, which is a <Suspense> boundary. For a slug that wasn't prerendered, Next.js starts streaming the response from that boundary, and the status code is sent with the first bytes. By the time the page runs notFound(), the 200 is already out. Next.js still renders the not-found UI and adds <meta name="robots" content="noindex">, so the page won't be indexed.
| URL | Status | Robots |
|---|---|---|
| /does-not-exist | 404 | noindex |
| /blog/nope | 200 | noindex |
| /case-studies/nope | 200 | noindex |
To get a real 404 status, the check has to happen before streaming starts, for example in a Proxy (the new name for middleware) that looks the slug up on every request. I decided against it: the noindex tag already keeps these URLs out of Google, and every visitor would pay for that extra check. For a content site, 200 + noindex is a reasonable trade-off. For an API or a site where status codes are monitored, it might not be.
4. Where the blog content comes from
Posts are JSON files. The obvious approach is to read the folder at render time. I chose static imports instead: one index.ts imports every file, so the JSON is part of the bundle, every post is known at build time, and there is no file-system read to cache or to forget in the deployment.
import nextjsLighthouse from "./blog/nextjs-lighthouse-79-to-99.json";
import cacheComponents from "./blog/nextjs-16-cache-components-migration.json";
export const rawPosts: unknown[] = [nextjsLighthouse, cacheComponents];The cost is one extra line per post. In return, a typo in a post's JSON fails the build with a clear message instead of breaking a page in production, and a script checks that every file in the folder is registered.
5. Smaller surprises in this version
- error.tsx props: in the version this site uses, the error boundary receives
{ error, retry }, notreset. Narrowerrorwithinstanceof Errorbefore reading.message. - Route segment configs:
dynamic,revalidateandfetchCacheexports error once the flag is on. Remove them and use"use cache"+cacheLife()where you really want caching. - Read the docs in node_modules: Next.js 16 ships its documentation inside the package (
node_modules/next/dist/docs/). It matches your installed version exactly, which matters while APIs are still moving.
The result
After the migration, every blog post, category page and case study shows as ○ (static) in the build output, and nothing on the content pages runs per request. Lighthouse on mobile, production build, median of three runs:
| Page | Performance | Accessibility / Best Practices / SEO |
|---|---|---|
| Home | 100 | 100 / 100 / 100 |
| Projects | 100 | 100 / 100 / 100 |
| Blog post | 91 | 100 / 100 / 100 |
| Case study | 90–100 | 100 / 100 / 100 |
The blog post and some case studies score lower because their largest element is the cover image; how I handled that is in the Lighthouse post.
Migration checklist
- Search for
new Date(,Date.now(,Math.random(andrandomUUID(in anything that renders. Cache the value with"use cache"+cacheLife(), or render it at request time withconnection()inside<Suspense>. - Delete every
dynamic,revalidate,fetchCacheanddynamicParamsexport. - Make sure every
generateStaticParams()returns at least one param. - Call
notFound()in dynamic pages when the param doesn't match real data. - Expect
200 + noindex(not404) for unknown params under aloading.tsx; decide if that is acceptable for your site. - Run
next buildand check that the routes you expect to be static show○.
Frequently asked questions
Do I have to use Cache Components in Next.js 16?
No. It is opt-in with cacheComponents: true in next.config. Without it, Next.js 16 keeps the previous caching model with route segment configs like revalidate.
Why does new Date() fail the build with Cache Components?
The value changes every time it runs, so Next.js won't silently freeze it into the prerendered HTML. Cache it with "use cache" and cacheLife(), or render it at request time by calling connection() inside a Suspense boundary.
Why does notFound() return a 200 status?
When the route has a Suspense boundary (such as loading.tsx) and the page isn't prerendered, the response starts streaming before notFound() runs, so the 200 status is already sent. Next.js adds a noindex meta tag so the page isn't indexed.
- Next.js 16
- Cache Components
- use cache
- App Router
Keep reading
FoodHub · Restaurant ordering & delivery · Australia
FoodHub: Building a White-Label Restaurant Ordering SaaS
A white-label SaaS for an Australian founder that lets any restaurant launch its own commission-free ordering and delivery website, with live rider tracking and Stripe Connect payouts. Built solo, end to end.
- Live on the platform
- 2 restaurants
- Storefront, admin console, API
- 3 apps

React & Next.js7 min read
Fix: "Next.js encountered uncached or runtime data during prerendering"
What the Next.js 16 Cache Components build error really means, why the stack trace can point at the wrong file, and three fixes I tested in a real build: Suspense, "use cache" and instant = false.

React & Next.js6 min read
Fix: "Next.js encountered the unstable value new Date() while prerendering"
Why Next.js 16 fails the build on new Date(), Date.now() or Math.random() with Cache Components, why "use client" alone doesn't fix it, and which of the fixes to use for your case.
