nextjs page router auto scroll
Answered
Northern snakehead posted this in #help-forum
Northern snakeheadOP
im having an issue with next page router and it auto snapping / storing weird scroll locations.
router.push(`/job-page/${project.id}`, undefined, { scroll: false });
is what im doing to transition and this is fine for this, but when users transition back to pages with the browser back arrow, the scroll behaves weirdly and snaps to a seemingly random location. Any helps appreciatedAnswered by Northern snakehead
yeah fs, and the fix was u can disable auto scroll like this
if (typeof window !== "undefined") {
window.history.scrollRestoration = "manual";
}
3 Replies
Northern snakeheadOP
solved
@Northern snakehead solved
Mind sharing the solution and losing the thread by marking it?
@LuisLl Mind sharing the solution and losing the thread by marking it?
Northern snakeheadOP
yeah fs, and the fix was u can disable auto scroll like this
if (typeof window !== "undefined") {
window.history.scrollRestoration = "manual";
}
Answer