Navigate from / to /other using location.pushState
Try to navigate back to / using Link or router.push
Current vs. Expected behavior
After navigating from / to /other using location.pushState, it still renders to content from / but shows the URL as /other. This is working as expected.
However, when trying to navigate back to / (to reset the page), using Link or router.push changes the URL back to / (as expected) but does not reset the page. This also happens with router.refresh (either before or after navigation).
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 14.1.1-canary.23 // Latest available version is detected (14.1.1-canary.23).
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/vercel-next-js-reproduction-template-go8s7s?file=%2Fapp%2Flayout.tsx%3A5%2C13
To Reproduce
/
to/other
usinglocation.pushState
/
usingLink
orrouter.push
Current vs. Expected behavior
After navigating from
/
to/other
usinglocation.pushState
, it still renders to content from/
but shows the URL as/other
. This is working as expected.However, when trying to navigate back to
/
(to reset the page), usingLink
orrouter.push
changes the URL back to/
(as expected) but does not reset the page. This also happens withrouter.refresh
(either before or after navigation).Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
No response