-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
@workos/authkit-react uses a natural React interface:
const { isLoading, user } = useAuth();This works great for typical React components.
It doesn't work very well with frameworks like Tanstack-Router and React-Router that have lifecycle hooks for fetching data that run before the component renders.
It would be really nice to be able to do this:
export const Route = createFileRoute('/authenticated')({
async beforeLoad({ context }) {
const { clientReady } = context.auth; // the result of useAuth
return clientReady.then((user) => {
if (!user) {
throw redirect({ to: '/auth/login' });
}
});
},
component:() => {
const { isLoading, user } = useAuth();
return "isLoading is never true here. User is always a user";
},
});Metadata
Metadata
Assignees
Labels
No labels