Open bohdan-mykhailenko opened 3 months ago
I'm experiencing the same issue, NextJS app router, version 14.2.5. Any update on this?
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/snowy-platform-7k39wy
To Reproduce
Page 1
andPage 2
routes to createwindow.history records
to be able to go back viabrowser arrow
.reload
page viabrowser reload button
orkeyboard
andgo back
toprevious route
(make it as fast as possible)updated URL
and the content from previous page (segment
) .step 3
.Current vs. Expected behavior
Actual result: page content is still from previous route and URL is correct. Expected result: page content where I go back and URL must be correct.
Provide environment information
Which area(s) are affected? (Select all that apply)
Navigation, Pages Router
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
That issue exists in all
Next.js 13+
that I tried to reproduce bug.Next.js 12
and the issue doesn't exist there.Here is the screen record from official Vercel website that also reproduces that issue.
Current way to fix. To fix that bug, I check for actual rendered segment, then check for what actually I have in URL and use
router.push
to URL with rendered segment. As I tested it's not possible to correctly change segment according to URL but it's possible to change URL according to rendered segment. But you need to configure that logic manually for a lot of segments so it's not the best option of course but at least we show correct content and URL for user.