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

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp