Next.js · sdk · fg-0298

Build fails with 'encountered the unstable value crypto.randomUUID()' after enabling cacheComponents

If you see Route "/account": Next.js encountered the unstable value `crypto.randomUUID()` while prerendering, the cause and the fix for Next.js are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Route "/account": Next.js encountered the unstable value `crypto.randomUUID()` while prerendering.The same error for `new Date()`, `Date.now()` or `Math.random()`Setting instant = false on the route does not make the error go away
Cause
With cacheComponents, Next.js prerenders a static shell and treats time, randomness and random bytes as IO that would freeze into it. Auth libraries often call crypto before reading headers, so the error points at code you did not write.
Fix
Wrap the part that needs the value in Suspense and call await connection() before the call so it runs per request, or cache it with use cache, or move it into a Client Component.
Apply
import { connection } from 'next/server' async function Account() { await connection() // mark request-time before auth() touches crypto const session = await auth() } // render <Account /> inside <Suspense>
Affected
Next.js 16.x with cacheComponents: true (reproduced on 16.4.1 with Auth.js)
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun