How do I get the previous route address?
Unanswered
Orinoco Crocodile posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Orinoco CrocodileOP
How do I get the previous route address in nextJS? I'm redirecting to my login window and want to return to the previous screen on complete
7 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Orinoco CrocodileOP
bump
![Avatar](https://cdn.discordapp.com/avatars/769111741098622976/a00ea6fb13337fd9ef76154f8e3cb990.webp?size=256)
Eric Burel
Check window.history
but ideally you would pass a query param to the rediection
like "login?from=/home"
use "encodeURIComponent" (and decodeURIComponent) in order to be able to shove a path into the URL while handling special chars
note that it makes the login page dynamic if you get searchParams from props, or client-side rendered if you use useSearchParams
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Orinoco CrocodileOP
Thanks!