nextjs - 💡(How to fix) Fix App Router (dev): `window.location.href` source page not re-hydrated on Back [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#93948Fetched 2026-05-20 03:38:28
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Error Message

  • No console.error or pageerror events fire.

Fix Action

Fix / Workaround

  • Dev only. next build && next start on the same code hydrates correctly. Confirmed via the same Playwright probe.
  • Bundler independent. Both Turbopack (default) and --webpack reproduce. Rules out a Turbopack-specific regression.
  • Not bfcache. pageshow.persisted === false, so the browser is doing a fresh load — Next's dev runtime simply doesn't kick off hydration on it.
  • Workaround: swap window.location.href = '/b' for a <Link href="/b"> or router.push('/b') (soft navigation). Soft nav keeps the React tree alive across the trip so there's no fresh load to hydrate on Back. Not viable when the destination is on a different host (the original use case in our app is www.example.comapp.example.com, where router.push can't cross origins).
RAW_BUFFERClick to expand / collapse

Verify canary release

I verified that the issue exists in [email protected] (latest stable as of filing). Happy to retest on canary if requested.

Provide environment information

  • Next.js: 16.2.4
  • React: 19.2.4
  • Node.js: 22.22.0
  • Platform: macOS 14.6 (darwin arm64)
  • Bundler: reproduces on both Turbopack and webpack dev

Which area(s) are affected?

App Router, Navigation, Turbopack, webpack

Which stage(s) are affected?

next dev only — next build + next start works correctly.

Link to the code that reproduces this issue

https://github.com/jason21000000/next-app-router-back-hydration-repro

To Reproduce

  1. Clone the repo above (three files: app/layout.tsx, app/page.tsx, app/b/page.tsx).
  2. npm i && npm run dev (Turbopack) or npm run dev:webpack.
  3. Open http://localhost:3050/.
  4. Click Counter — increments. (Proves initial hydration works.)
  5. Click Hard-nav to /b — navigates via window.location.href = '/b'.
  6. Click browser Back.
  7. Click Counterdoes nothing. The button is dead HTML.

Verify in devtools on the post-Back page:

  • document.querySelector('button') has no __reactFiber* / __reactProps* keys.
  • performance.getEntriesByType('navigation')[0].type === 'back_forward'.
  • pageshow.persisted is false (so this is a fresh load, not bfcache restore).
  • All JS chunks load with HTTP 200.
  • No console.error or pageerror events fire.

Describe the Bug

When the source page of a window.location.href-style hard navigation is returned to via the browser's Back button, React never bootstraps on the restored page in next dev. The HTML and CSS render, all JS chunks fetch successfully, but hydrateRoot is never called — every DOM node lacks React fibers and every interactive element is dead HTML. There are no console errors; the failure is silent.

Expected Behavior

The source page should hydrate on Back-restore just as it does on initial load. This is the behavior in next build + next start (verified on the same repro) and presumably the intended behavior in dev.

Additional context

  • Dev only. next build && next start on the same code hydrates correctly. Confirmed via the same Playwright probe.
  • Bundler independent. Both Turbopack (default) and --webpack reproduce. Rules out a Turbopack-specific regression.
  • Not bfcache. pageshow.persisted === false, so the browser is doing a fresh load — Next's dev runtime simply doesn't kick off hydration on it.
  • Workaround: swap window.location.href = '/b' for a <Link href="/b"> or router.push('/b') (soft navigation). Soft nav keeps the React tree alive across the trip so there's no fresh load to hydrate on Back. Not viable when the destination is on a different host (the original use case in our app is www.example.comapp.example.com, where router.push can't cross origins).

I'd love to know whether this is a known regression or a Next-dev-runtime quirk worth documenting. Happy to provide more diagnostics — I have a Playwright probe that asserts the fiber-missing state if useful for a regression test.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix App Router (dev): `window.location.href` source page not re-hydrated on Back [1 participants]