Next.js Discord

Discord Forum

How can i autoscroll to the very top each time you enter a new route?

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Each time i enter a different route, the scroll maintains the position it had on the previous page.

I've tried scroll={} to try to understand the behavior but i can't figure it out.
I've also tried
useEffect(() => {
     window.scrollTo(0, 0)
}, [pathname])
using a scroller component to wrap my layout

0 Replies