T
TanStack2y ago
afraid-scarlet

Is there any way to programmatically trigger redirect using file based routing?

I have a callback which listens for changes on a user object. I've rigged it such that when the callback is called, it would redirect the user based on the arguments passed into the callback. The only problem is that the redirect doesn't actually work. Please help
No description
No description
16 Replies
fascinating-indigo
fascinating-indigo2y ago
Navigation | TanStack Router Docs
Everything is Relative Believe it or not, every navigation within an app is relative, even if you aren't using explicit relative path syntax (../../somewhere). Any time a link is clicked or an imperative navigation call is made, you will always have an origin path and a destination path which means you are navigating from one route to another ...
afraid-scarlet
afraid-scarletOP2y ago
yeah I saw this lemme take a screenshot of the error I get when I try this
fascinating-indigo
fascinating-indigo2y ago
I think I understand what you trying to do I think you should have the auth checking login in the route beforeload, and when auth changes just invalidate the router context
afraid-scarlet
afraid-scarletOP2y ago
No description
fascinating-indigo
fascinating-indigo2y ago
is your auth provider above the router provider?
afraid-scarlet
afraid-scarletOP2y ago
oh okay
fascinating-indigo
fascinating-indigo2y ago
make sure your router is the highest provider I think thats the issue
afraid-scarlet
afraid-scarletOP2y ago
yes it is
No description
fascinating-indigo
fascinating-indigo2y ago
nope
afraid-scarlet
afraid-scarletOP2y ago
ohhh yeah so stupid of me
fascinating-indigo
fascinating-indigo2y ago
haha these stuff happen, life of a web developer
afraid-scarlet
afraid-scarletOP2y ago
it works now, thanks so much 😁 is there any need to close this channel or mark it as answered?
fascinating-indigo
fascinating-indigo2y ago
try to see if you can mark this as the answer, not sure how these stuff work
afraid-scarlet
afraid-scarletOP2y ago
okay
generous-apricot
generous-apricot2y ago
You can mark the thread as resolved by using the ✅ reaction on the original/first post in the thread.
afraid-scarlet
afraid-scarletOP2y ago
okay thanks

Did you find this page helpful?