-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathauth.ts
More file actions
54 lines (47 loc) · 1.32 KB
/
Copy pathauth.ts
File metadata and controls
54 lines (47 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import "@tanstack/react-start/server-only";
import { drizzleAdapter } from "@better-auth/drizzle-adapter/relations-v2";
import { betterAuth } from "better-auth/minimal";
import { tanstackStartCookies } from "better-auth/tanstack-start";
import { env } from "#/env/server.ts";
import { db } from "#/lib/db/index.ts";
import * as schema from "#/lib/db/schema/index.ts";
export const auth = betterAuth({
baseURL: env.VITE_BASE_URL,
telemetry: {
enabled: false,
},
database: drizzleAdapter(db, {
provider: "pg",
schema,
}),
// https://better-auth.com/docs/integrations/tanstack#usage-tips
plugins: [tanstackStartCookies()],
// https://better-auth.com/docs/concepts/session-management#session-caching
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60, // 5 minutes
},
},
// https://better-auth.com/docs/concepts/oauth
socialProviders: {
github: {
clientId: env.GITHUB_CLIENT_ID!,
clientSecret: env.GITHUB_CLIENT_SECRET!,
},
google: {
clientId: env.GOOGLE_CLIENT_ID!,
clientSecret: env.GOOGLE_CLIENT_SECRET!,
},
},
// https://better-auth.com/docs/authentication/email-password
emailAndPassword: {
enabled: true,
},
advanced: {
database: {
// https://better-auth.com/docs/adapters/drizzle#joins
joins: true,
},
},
});