Best practice for type-safe redirects #4764
Unanswered
GarrisonBates
asked this question in
Q&A
Replies: 1 comment 1 reply
-
where do you want to throw that redirect? what do you want to do with the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm currently transitioning from React Router and have functionality that looks something like this:
This worked fine, but now with Tanstack Router I'd like to make it type safe. I was thinking there'd be an exported type that would cover all possible URL paths, but this is the best I could come up with:
And then do something like this:
But even then, I get type error because
routerState.fullPath
can be""
, which isn't included in the HistoryState type derived from FileRoutesByFullPath. Also, I feel like there's got to be a better way than useRouterState to get the current path? I'm still familiarizing myself with Tanstack Router's APIs, so if there's an obvious drop-in for this use case I'd appreciate some input.Beta Was this translation helpful? Give feedback.
All reactions