Description
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/red-night-gzxtd3?workspaceId=ws_6n6a3ybSgRKyAi1WWXUV6w
To Reproduce
I encountered an issue when using Intercepting Routes for modal pages in the App Router. Here's the flow to reproduce:
Reproduction Steps:
Navigate to / (or any normal page).
Open a modal by navigating to an intercepting route like (..)signin.
From there, navigate to another intercepting route, e.g. (..)signup.
Refresh the browser while on the (..)signup route.
Click the browser's back button to go back to (..)signin.
Current vs. Expected behavior
Expected behavior:
The app should correctly render the (..)signin modal once.
Actual behavior:
The component at (..)signin re-renders infinitely, causing performance issues or even a crash.
Additional context:
This only happens after refreshing the second modal route ((..)signup).
The re-render does not stop; console.log in the modal component confirms it gets called repeatedly.
It seems like after a refresh, the browser history and route state get misaligned, causing router.back() or the transition to improperly remount or retrigger the intercepting route.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 22.11.0
npm: 10.9.0
Yarn: N/A
pnpm: 9.12.3
Relevant Packages:
next: 15.3.3 // Latest available version is detected (15.3.3).
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Parallel & Intercepting Routes
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response