TanStack · Pipe
beforeLoad
Use a route's beforeLoad function to check authentication before the route and its children load. Throw redirect() to send unauthenticated users to login, while private server data still needs its own authorization.
Last updated
Syntax
beforeLoad: ({ context, location }) => { if (!context.auth.isAuthenticated) throw redirect({ to: '/login' }) }In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
redirect()route.loaderPathless RouteLayout RouteAuthenticated RoutesAuthentication Server Primitives