
On this page
The most common place to hit this error is the most boring line in your app: the copyright year in the footer. With Cache Components on, new Date() during prerendering fails the build, and so do Date.now(), Math.random() and crypto.randomUUID().
I hit it on this site's footer, and I reproduced it again on Next.js 16.4.6 to test every fix the error message suggests. One of them doesn't work the way you'd expect.
The full error
export default function Page() {
return <p>© {new Date().getFullYear()}</p>;
}Error: Route "/zz-date": Next.js encountered the unstable value `new Date()` while prerendering.
This value can change between renders, so it must be either prerendered or computed later.
Ways to fix this:
- [dynamic] Render at request time by adding a dynamic data access (e.g. `await connection()`) before this call
- [cache] Prerender and cache the value with `"use cache"`
- [client] Render the value on the client with `"use client"`
- [measure] If the value is for telemetry, use a timing API such as `performance.now()`
Learn more: https://nextjs.org/docs/messages/blocking-prerender-current-timeHere the code frame pointed at the right line (page.tsx:2:16), unlike the uncached data error, where it pointed at an unrelated provider.
Why Next.js refuses new Date()
Cache Components prerenders a static shell at build time. If new Date() ran during that prerender, the value from the moment of the build would be frozen into the HTML and served to every visitor, possibly for months. Next.js won't do that silently. You have to say which of these you mean:
- "Freeze it, refresh it sometimes": cache the value.
- "Compute it fresh for every request": render that part at request time.
- "Compute it in the visitor's browser": move it to the client, after hydration.
Fix 1: cache it (copyright years, build dates)
A copyright year changes once a year. Rendering it per request would make the whole page dynamic for nothing. This is the component this site's footer uses:
import { cacheLife } from "next/cache";
export async function CurrentYear() {
"use cache";
cacheLife("days");
return <>{new Date().getFullYear()}</>;
}The page built as ○ (Static). cacheLife("days") makes Next.js recompute the value at most about once a day, so the footer still rolls over to the new year without a redeploy.
Fix 2: render it at request time (per-request timestamps)
If the value really must be fresh on every request (a "generated at" time, a server-side countdown), call await connection() before reading the clock, and wrap that component in <Suspense> so the rest of the page keeps its static shell:
import { Suspense } from "react";
import { connection } from "next/server";
async function GeneratedAt() {
await connection();
return <p>Generated at {new Date().toISOString()}</p>;
}
export default function Page() {
return (
<>
<h1>Status</h1>
<Suspense fallback={<p>Loading…</p>}>
<GeneratedAt />
</Suspense>
</>
);
}Fix 3: "use client" is not enough on its own
The error suggests rendering the value on the client, so I moved the year into a Client Component:
"use client";
export function Year() {
return <>{new Date().getFullYear()}</>;
}The build failed again, with a different message. Client Components are prerendered on the server too, so the clock still runs during the build:
Error: Route "/zz-client-date": Next.js encountered the unstable value `new Date()` in a Client Component.
This value would be evaluated during the prerender, instead of recomputed on each visit.
Ways to fix this:
- [stream] Wrap the Client Component in `<Suspense fallback={...}>`
- [defer] Move the read into a `useEffect` or event handler
- [measure] If the value is for telemetry, use a timing API such as `performance.now()`
Learn more: https://nextjs.org/docs/messages/blocking-prerender-current-time-clientSo in a Client Component, read the clock after render: in useEffect, or in an event handler. This is the right choice for things that should show the visitor's own time, like "5 minutes ago" labels or a countdown:
"use client";
import { useEffect, useState } from "react";
export function TimeAgo({ iso }: { iso: string }) {
const [label, setLabel] = useState<string | null>(null);
useEffect(() => {
const minutes = Math.round((Date.now() - Date.parse(iso)) / 60000);
setLabel(`${minutes} min ago`);
}, [iso]);
// The prerendered HTML shows the plain date until the browser fills in the label.
return <time dateTime={iso}>{label ?? iso.slice(0, 10)}</time>;
}Fix 4: measuring time? Use performance.now()
If you only read the clock to measure how long something took (logging, telemetry), use performance.now(). The error message lists it as allowed: it measures elapsed time, it doesn't tell the time of day, so there is nothing to freeze into the HTML.
You may not need the clock at all
Formatting a date you already have (a post's publishedAt, an order date from the database) is not the problem. The problem is asking "what time is it now?". This blog stores dates as ISO strings ("2026-11-20") and formats them without ever calling new Date() during render, so the post pages stay fully static.
Which fix to pick
| What you're showing | Fix | Result |
|---|---|---|
| Copyright year, "last updated" from the build | "use cache" + cacheLife() | Page stays ○ Static |
| A value that must be fresh per request | await connection() inside <Suspense> | ◐ Partial Prerender |
| "5 min ago", countdowns, the visitor's local time | Client Component + useEffect | Static HTML, filled in by the browser |
| Timing code for logs or metrics | performance.now() | No change needed |
The same rules apply to Math.random() and crypto.randomUUID(): cache the value, generate it per request inside Suspense, or generate it in the browser. Before turning Cache Components on, search your code for new Date(, Date.now(, Math.random( and randomUUID( in anything that renders. More migration notes: Next.js 16 Cache Components: what broke and the fixes.
Frequently asked questions
Why does new Date() fail the build in Next.js 16?
With Cache Components on, Next.js prerenders a static shell at build time. A value from new Date() would be frozen into that HTML, so Next.js makes you choose: cache it with "use cache", compute it per request with connection() inside Suspense, or compute it in the browser.
Does moving new Date() to a Client Component fix it?
Not on its own. Client Components are prerendered too, so Next.js reports "encountered the unstable value new Date() in a Client Component". Read the clock in useEffect or an event handler, or wrap the Client Component in Suspense.
How do I show the current year in the footer with Cache Components?
Put it in an async Server Component with "use cache" and cacheLife("days"). The page stays static and the year is recomputed about once a day.
Does this also apply to Math.random() and crypto.randomUUID()?
Yes. They are unstable values too, with the same choices: cache the value, generate it per request inside Suspense, or generate it in the browser.
- Next.js 16
- Cache Components
- use cache
- Errors
Keep reading
Vizlio · Web design & development agency · Australia
Vizlio: A CMS-Powered Agency Website with a Custom AI Chatbot
The website, admin panel and AI assistant for Vizlio, an Australian web design and development agency. Every page is editable from the admin panel, and a custom-trained chatbot answers visitors' questions about the business. Built solo.
- Website, admin panel and AI chatbot
- 3 in 1
- Site content editable from the admin panel
- 100%

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.js7 min read
Next.js 16 Cache Components: What Broke When I Turned It On (and the Fixes)
I enabled Cache Components on this site, a Next.js 16 portfolio with a blog and case studies. Here is every error and surprise I hit, why it happens, and the exact code that fixed it.
