Menu

1 / 5

Fix: “Next.js encountered the unstable value new Date()” in Next.js 16

DEV Community: react·Nando Septian Husni·17 days ago
#rQwq41rn
#devtoreact#devto#dev#value#next
Long article (1196 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.