Navigating back to previous page
So i am trying to create a back button in a web app which s working fine using
history.back()
but the problem is if i copy paste the link and then i hit the back button the user will go back to the previous tab even if its not our domain. i want the user to go to home page if previous page is not a page from our hostname
using react-router-dom
for navigation
1 Reply
sessionStorage
the page urls during a visit in a list and use that to navigate back.
it will require some extra logic that i'm not able to provide you right now. But maybe this is enough for you to get on track.
just thinking. for your use case you might also get away with document.referrer
it will give you the url of the page that linked to the current page. if there is none, it will return empty (page was opened directly)