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