persist user vertical scroll during navigation between pages NEXT 13 App Dir
i wanna learn how to keep the user where he was during navigation between pages like, open blog post, then go back to feed, but keeping the feed vertical scroll history
i'm using server components, the issue is the page is rendered then the javascript loads and moves the user to desired position, garbage ux
3 Replies
You can probably store last visible post in the feed in a context or global store and scroll to that when user goes back to feed page
javascript moving the user viewheight is a poor ux because it runs afterwards, the behavior i'm aiming is something like stack navigation, the post is open in front, but the feed page still there, when user goes back, he just closes the post layer and feed still there, untouched
We can do a stack in a couple of ways, one concern with this approach might be what happens if user refreshes the browser while on the post page. What should be the user experience then.