Getting the destination url in the loader to throw a redirect
When you are throwing a redirect in a Route loader, is there any built-in way to get a string with the intended destination (path + search params) for the current Route?
The use-case here is an auth scenario where I'd place a string in a
redirect_url search params to navigate to once auth is completed or on oauth2 callback.
Or should I just be creating this myself by parsing window.location into a string?4 Replies
fair-rose•3y ago
router.state.location.href
ratty-blushOP•3y ago
Thanks!
Just to confirm, I would import this Router into my into the individual route file and then use
router.state.location.href?
https://github.com/SeanCassiere/nv-rental-clone/blob/master/src/app-entry.tsx#L21GitHub
nv-rental-clone/src/app-entry.tsx at master · SeanCassiere/nv-renta...
Navotar with Tailwind and the Tanstack. Contribute to SeanCassiere/nv-rental-clone development by creating an account on GitHub.
probable-pink•3y ago
yeah or in layout
ratty-blushOP•3y ago
For me, the layout method wouldn't work since I'm doing the logic checking for that in the loader itself.
Will give it a shot.