0

I have setup an application using a startup created by NEXTJS version 13 and sanity.io v3. The blog application is amazingly fast but the problem is that when I (or possibly any other user) clicks and visit a post, and then goes back to main page (i.e. index page) , the index automatically scroll to top instead of staying at same position where user left it.

The link of the demo application is here. please visit and check how this problem can be solved out.

https://sanity-tech-blog.vercel.app/

Please spend some precious time to solve it out.

The startup that is used is here

https://vercel.com/templates/next.js/blog-nextjs-sanity

Nil
  • 1,209
  • 9
  • 20
  • Does this answer your question? [How can I retain the scroll position of a scrollable area when pressing back button?](https://stackoverflow.com/questions/29203312/how-can-i-retain-the-scroll-position-of-a-scrollable-area-when-pressing-back-but) – Aᴍɪʀ Jan 04 '23 at 05:37
  • One of the methods work for me, however, there is one more issue. I saved current scroll position in localStorage, and now if a user even refresh the main page/ index page (where all blog posts are lying), then the page takes scroll position value from the localStorage and automatically scrolled to that position. But I want to remove or reset localStorage value when there is a page redress. – kashif Riaz Jan 05 '23 at 11:04

0 Answers0