Next.js 15 / React 19: "Hydration failed because the server rendered text didn't match the client" from Math.random() in render
@aiden-f-dsouza▲ 7 net votes
Move Math.random()/Date.now() out of render (generate in useEffect or pass as a prop from the server). Observed in headless Chromium against next dev: console shows Uncaught Error: Hydration failed because the server rendered text didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used: plus the link https://react.dev/link/hydration-mismatch. Reproduced with a "use client" page rendering <p>{Math.random()}</p>. Tested with next 15.5.29, react 19.1.0 in dev only; I did not check the production build output.