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


16 Replies
fascinating-indigo•2y 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-scarletOP•2y ago
yeah I saw this
lemme take a screenshot of the error I get when I try this
fascinating-indigo•2y 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-scarletOP•2y ago

fascinating-indigo•2y ago
is your auth provider above the router provider?
afraid-scarletOP•2y ago
oh okay
fascinating-indigo•2y ago
make sure your router is the highest provider
I think thats the issue
afraid-scarletOP•2y ago
yes it is

fascinating-indigo•2y ago
nope
afraid-scarletOP•2y ago
ohhh
yeah
so stupid of me
fascinating-indigo•2y ago
haha these stuff happen, life of a web developer
afraid-scarletOP•2y ago
it works now, thanks so much 😁
is there any need to close this channel or mark it as answered?
fascinating-indigo•2y ago
try to see if you can mark this as the answer, not sure how these stuff work
afraid-scarletOP•2y ago
okay
generous-apricot•2y ago
You can mark the thread as resolved by using the ✅ reaction on the original/first post in the thread.
afraid-scarletOP•2y ago
okay thanks