Open History to see the last commit
1import { Button, Flex, Heading, Text } from '@radix-ui/themes';
2import { Link, createFileRoute } from '@tanstack/react-router';
3import { getAuth, getSignInUrl } from '@workos/authkit-tanstack-react-start';
4import SignInButton from '../components/sign-in-button';
5β
6export const Route = createFileRoute('/')({
7 component: Home,
8 loader: async () => {
9 const { user } = await getAuth();
10 const url = await getSignInUrl();
11 return { user, url };
12 },
13});
14β
15function Home() {
16 const { user, url } = Route.useLoaderData();
17β
18 return (
19 <Flex direction="column" align="center" gap="2">
20 {user ? (
21 <>
22 <Heading size="8">Welcome back{user?.firstName && `, ${user?.firstName}`}</Heading>
23 <Text size="5" color="gray">
24 You are now authenticated into the TanStack Start application
25 </Text>
26 <Flex align="center" gap="3" mt="4">
27 <Button asChild size="3" variant="soft">
28 <Link to="/account">View account</Link>
29 </Button>
30 <SignInButton url={url} user={user} large />
31 </Flex>
32 </>
33 ) : (
34 <>
35 <Heading size="8">AuthKit authentication example</Heading>
36 <Heading size="7">TanStack Start</Heading>
37 <Text size="5" color="gray" mb="4">
38 Sign in to view your account details
39 </Text>
40 <SignInButton user={user} url={url} large />
41 </>
42 )}
43 </Flex>
44 );
45}