TanStackT
TanStack2y ago
4 replies
moderate-tomato

Is it possible to narrow auth type on authenticated routes?

Hi,
for the sake of simplicity, let's talk about authenticated routes example from the documentation: https://tanstack.com/router/latest/docs/framework/react/examples/authenticated-routes
If you look at _auth.dashboard.tsx, auth.user is of type string | null. I would like it to be just
string
, since I assume the user to be valid at this point.

If I should not do this and instead redirect to login on invalid user in each route, what would be the reasons for that?
An example showing how to implement Authenticated Routes in React using TanStack Router.
React TanStack Router Authenticated Routes Example | TanStack Route...
Was this page helpful?