Open History to see the last commit
1import Auth0 from '@auth/core/providers/auth0'
2import { setCookie } from '@tanstack/react-start/server'
3import type { Profile } from '@auth/core/types'
4import type { StartAuthJSConfig } from 'start-authjs'
5β
6declare module '@auth/core/types' {
7 export interface Session {
8 user: {
9 name: string
10 email: string
11 sub: string
12 email_verified: boolean
13 } & Profile
14 account: {
15 access_token: string
16 }
17 expires: Date
18 }
19}
20β
21/**
22 * Auth.js configuration for TanStack Start with Auth0
23 */
24export const authConfig: StartAuthJSConfig = {
25 // basePath is derived from AUTH_URL env var
26 secret: process.env.AUTH_SECRET,
27 providers: [
28 Auth0({
29 // Auth.js auto-reads AUTH_AUTH0_ID, AUTH_AUTH0_SECRET, AUTH_AUTH0_ISSUER from env
30 authorization: {
31 params: {
32 scope: 'email email_verified openid profile',
33 prompt: 'login',
34 },
35 },
36 async profile(profile, tokens) {
37 await setCookie(
38 'auth0Token',
39 encodeURIComponent(tokens.access_token ?? ''),
40 )
41 await setCookie(
42 'auth0User',
43 encodeURIComponent(JSON.stringify(profile)),
44 )
45β
46 return profile
47 },
48 }),
49 ],
50}