Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

index.tsx

55 lines1.6 KB

1import { createFileRoute } from '@tanstack/solid-router'
2import { Show } from 'solid-js'
3​
4export const Route = createFileRoute('/')({
5 component: Home,
6})
7​
8function Home() {
9 const routeContext = Route.useRouteContext()
10​
11 return (
12 <div class="max-w-2xl mx-auto">
13 <h1 class="text-3xl font-bold mb-4">TanStack Start Auth.js Example</h1>
14 <p class="text-gray-600 mb-8">
15 This example demonstrates auth.js integration with TanStack Start using
16 Auth0 OAuth.
17 </p>
18​
19 <div class="bg-gray-50 rounded-lg p-6">
20 <h2 class="text-xl font-semibold mb-4">Auth Status</h2>
21​
22 <Show
23 when={routeContext().session}
24 fallback={
25 <p class="text-gray-500">
26 You are not signed in. Click "Sign In" in the navigation bar to
27 authenticate with Auth0.
28 </p>
29 }
30 >
31 {(session) => (
32 <div class="space-y-2">
33 <p class="text-green-600 font-medium">Authenticated</p>
34 <Show when={session().user?.image}>
35 {(image) => (
36 <img
37 src={image()}
38 alt="Avatar"
39 class="w-16 h-16 rounded-full"
40 />
41 )}
42 </Show>
43 <p>
44 <strong>Name:</strong> {session().user?.name ?? 'N/A'}
45 </p>
46 <p>
47 <strong>Email:</strong> {session().user?.email ?? 'N/A'}
48 </p>
49 </div>
50 )}
51 </Show>
52 </div>
53 </div>
54 )