TanStackT
TanStackโ€ข2y agoโ€ข
3 replies
inadequate-blush

Best approach for navigation back and forward?

I wonder what's the best way to handle situations like that:
- let's say I have paginated page /posts
- /posts/1 is a single post page which has 'back' link inside
If there would be no such a button, user would be forced to use browser navigation which would go back to the previous page (not push another route). As far as I understand, I can use history.go(-1), but if user has just directly opened the /posts/1 page , that would redirect him to the page he initialy came from. Of course I can pass some search params like backURL, but the downside of this is that it pushes a new route to the history. Is there something like in-app router history, that would remember the previous in-app pages?
I hope it's not a stupid question ๐Ÿ™‚
Was this page helpful?