Next.js · sdk · fg-0298
Build fails with 'encountered the unstable value crypto.randomUUID()' after enabling cacheComponents
Route "/account": Next.js encountered the unstable value `crypto.randomUUID()` while prerendering.
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
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>Affects: Next.js 16.x with cacheComponents: true (reproduced on 16.4.1 with Auth.js)
Sources
- https://nextjs.org/docs/app/guides/migrating-to-cache-components
- https://nextjs.org/docs/messages/blocking-prerender-crypto
- https://nextjs.org/docs/app/api-reference/functions/connection
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp