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 >
Enter fullscreen mode
Exit fullscreen mode
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()`
Enter fullscreen mode
Exit fullscreen mode
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.…