Open History to see the last commit
1import { createFileRoute, redirect } from '@tanstack/react-router';
2import { getAuth, getSignInUrl } from '@workos/authkit-tanstack-react-start';
3β
4export const Route = createFileRoute('/_authenticated')({
5 loader: async ({ location }) => {
6 // Loader runs on server (even during client-side navigation via RPC)
7 const { user } = await getAuth();
8 if (!user) {
9 const path = location.pathname;
10 const href = await getSignInUrl({ data: { returnPathname: path } });
11 throw redirect({ href });
12 }
13 },
14});