AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Next.Js Pages Router Race Condition Causes Hydration Mismatch Under Parallel Client-Side Navigations

Under concurrent client-side navigations using router.push, Next.js 16 Pages Router may deliver mismatched getServerSideProps data to the wrong navigation, causing React hydration errors. Regression from Next.js 15.3.2.

highConfidence 85%Next.jsAffected V16.0.0Affected V16.1.0Affected V16.2.0Affected V16.2.9

Origin Analysis

A race condition in the Next.js Pages Router's client-side data fetching: multiple concurrent router.push calls spawn overlapping fetchNextData requests, and the router incorrectly associates responses with the navigation context, leading to stale or incorrect pageProps being used for rendering and hydration.
1. Set up a Next.js 16 Pages Router project with a page using getServerSideProps that returns a dynamic value (e.g., incrementing counter). 2. Run the app and open multiple browser pages. 3. From each page, simultaneously call window.next.router.push for different routes or the same route multiple times. 4. Observe console errors: Hydration failed because server rendered text didn't match client.

Fixing Code Block

Edge Case Audit

This workaround reduces client-side navigation concurrency, potentially increasing perceived latency for rapid navigation. It may also affect applications that rely on overlapping navigations or expect push to be abortable. Rollback: remove the monkey-patch and restore default Router.push/replace after official fix. Test thoroughly in production-like concurrency scenarios.

Ecosystem Topology