I need to get the previous url in a nextjs project. I found this but it doesn't help because it always prints me the base url (http://localhost:3000/
) with this method (document.referrer
). I also tried to push a state into window.history based on official developer mozilla doc.
In the last case I click on a link and it redirects me to another page. On this page I need to know where I come from. I tried:
//pathname is a string containing the actual pathname
history.pushState({prevPath: pathname},pathname)
If I print history in the new page then I don't see any prevState in the state field.