TanStack Router Docs Wrong? - Auth Example
Is it possible this is a typo?
https://tanstack.com/router/latest/docs/framework/react/guide/authenticated-routes
Under redirecting
Though if you look at redirect in tanstack router
Shouldn't it be href and not to?
https://tanstack.com/router/latest/docs/framework/react/guide/authenticated-routes
Under redirecting
// src/routes/_authenticated.tsx
export const Route = createFileRoute('/_authenticated')({
beforeLoad: async ({ location }) => {
if (!isAuthenticated()) {
throw redirect({
to: '/login',
search: {
// Use the current location to power a redirect after login
// (Do not userouter.state.resolvedLocationas it can
// potentially lag behind the actual current location)
redirect: location.href,
},
})
}
},
})
Though if you look at redirect in tanstack router
export type Redirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom, TMaskTo extends string = ''> = {
/
* @deprecated UsestatusCodeinstead
/
href?: string;
code?: number;
statusCode?: number;
throw?: any;
headers?: HeadersInit;
} & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
Shouldn't it be href and not to?

Authentication is an extremely common requirement for web applications. In this guide, we'll walk through how to use TanStack Router to build protected routes, and how to redirect users to login if they try to access them.
The route.beforeLoad Option
The route.beforeLoad Option
