next.js: After refresh, browser back button is not working.
Bug report
Describe the bug
After refresh, browser back button is not working.
To Reproduce
It even reproduces on now.sh!
- Go to https://zeit.co/home
- Click on top left “pricing” navigation button
- Browser refresh with
cmd+r - Browser back button -> It just stays still.
Expected behavior
It should go back to ‘/home’
Screenshots

System information
- OS: macOS Catalina 10.15
- Browser : Chrome(Version 78.0.3904.97 (Official Build) (64-bit)) and safari(Version 13.0.2 (15608.2.30.1.1)) both reproduces this issue.
- Version of Next.js: I checked the latest version also reproduces this issue.
Additional context
I can also reproduce with this example repo, which uses the latest next.js
npx create-next-app --example hello-world hello-world-app
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 15 (4 by maintainers)
Thanks for reporting this!
Not really a NextJS issue but hopefully could help someone how’s reading this 👀
The backward navigation of my app would stop working out of the blue: I would hit back (either browser of router.back()), the url would change but the page would not. After hours of debugging and many coffees later I realised that a library I am using was setting
history.statetonullfor the route wherehistory.backwould stop working. Removing that logic restored the correct behaviour.Definitely a problem caused by external logic but I am wondering whether Next could be louder about it and possibly log an error 🤔 - thoughts?
checked it on 8.1.1-canary.39 works there. so it only broke recently.