I upgraded a landing page to Next.js 16 and the production build failed on the most innocent line in the whole project, the copyright year in the footer:
<p>© {new Date().getFullYear()} Driftly</p> next build stopped with this:
Error: Route "/": 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()` Here's why it happens and how to pick the right fix.
Why Next.js 16 complains
The error only shows up when Cache Components is turned on. Check your next.config.ts:
const nextConfig: NextConfig = { cacheComponents: true, }; My project was created with create-next-app, and it already had this option enabled.
With Cache Components, Next.js prerenders as much of each page as it can into static HTML at build time. A value like new Date() is different every time it runs, so Next.js can't tell whether you meant "the time when the site was built" or "the time when the visitor opened the page". Instead of guessing, it stops the build and asks you to decide.
The same rule applies to:
-
new Date()andDate.now() Math.random()crypto.randomUUID()
performance.now() is the exception. Next.js treats it as a timing tool for telemetry and doesn't guard it.
Fix 1: Cache the value with "use cache"
Use this when the value only needs to be fresh enough, not computed for every visitor. A copyright year is the perfect example.
Move the value into an async function marked with "use cache":
// components/year.tsx async function getYear() { "use cache"; return new Date().getFullYear(); } export async function Year() { return <>{await getYear()}</>; } // components/footer.tsx import { Year } from "./year"; export function Footer() { return <p>© <Year /> Driftly</p>; } The year is computed during prerendering and cached, so the page stays fully static. The cached value is refreshed when the cache revalidates or when you redeploy.
Fix 2: Compute it on every request with connection()
Use this when every visitor really needs a new value, like a request ID or a "rendered at" timestamp.
Call connection() before reading the value. This tells Next.js to wait for a real request. Wrap the component in <Suspense> so the rest of the page can still be prerendered:
import { connection } from "next/server"; import { Suspense } from "react"; async function RenderedAt() { await connection(); return <p>Rendered at {new Date().toISOString()}</p>; } export default function Page() { return ( <Suspense fallback={<p>Loading…</p>}> <RenderedAt /> </Suspense> ); } The trade-off: this part of the page is now rendered on the server for every request. In the next build output, the route changes from ○ (Static) to ◐ (Partial Prerender): static HTML with the dynamic part streamed in.
Fix 3: Move it to the client (and watch for the second error)
My first instinct was to make the footer year a Client Component:
"use client"; export function Year() { return <>{new Date().getFullYear()}</>; } That produced a different error:
Error: Route "/": 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. With Cache Components, Client Components are prerendered too. "use client" alone doesn't move the work to the browser. The error message suggests two ways out:
Read the value in an effect, so it only runs in the browser:
"use client"; import { useEffect, useState } from "react"; export function LocalTime() { const [time, setTime] = useState<string | null>(null); useEffect(() => { setTime(new Date().toLocaleTimeString()); }, []); return <span>{time ?? "…"}</span>; } Or wrap the Client Component in <Suspense> so Next.js can stream it in instead of baking it into the static HTML.
Use this fix for values that depend on the visitor's browser, such as their local time zone.
Fix 4: For telemetry, use performance.now()
If you only need a duration for logging, performance.now() is allowed:
const start = performance.now(); await doWork(); console.log(`doWork took ${performance.now() - start}ms`); Don't render this value in the UI. It's meant for measurements.
Which fix should you use?
| What you need | Fix |
|---|---|
| A value that's fine to compute once (copyright year, build date) | "use cache" |
| A fresh value for every request (request ID, server timestamp) | await connection() + <Suspense> |
| A value from the visitor's browser (local time, time zone) | useEffect in a Client Component |
| A duration for logs or metrics | performance.now() |
One more gotcha: static export
If you deploy with output: "export" (a fully static site with no server), you can't render anything per request, so Fix 2 is not an option. For the static demo of my landing page, the simplest working setup was turning cacheComponents off for that build. Note that partialPrefetching requires cacheComponents, so it has to go too.
Wrapping up
The error looks scary, but it's Next.js asking a fair question: should this value be computed once, per request, or in the browser? Answer that, and the fix is a few lines.
The official docs go deeper: blocking-prerender-current-time and the Client Component version.
I ran into this while building Liftoff, a Next.js 16 + Tailwind CSS 4 landing page kit, which uses the "use cache" footer year from Fix 1.
- Liftoff Lite is free (MIT): navbar, hero, features, footer and dark mode. Get Liftoff Lite
- Liftoff is the full kit with pricing, FAQ, testimonials, email capture and a 22-page launch guide. Live demo · Get Liftoff
Have you hit this error with something other than dates? Let me know in the comments.

