On my web app I have a blog. On each post there are a back button, not the browser back button, which should lead the user back to where they came from. Since the blog post can be linked from multiple routes I can't have a static back path. Therefore I tried using the route.back()
method. However if the user came from Facebook or another site they will go back to that site. I understand that this is the intended behavior of the method but I don't think that is what the user expects when they press the custom back button. Instead I want to route them back to the homepage.
I have tried using the document.referrer
but since I use Next.js document.referrer
is always empty. Also this soloution is not working anymore.
Have I missed something or is there any other elegant or non-elegant solutions?