-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathauth.ts
More file actions
52 lines (45 loc) · 1.3 KB
/
auth.ts
File metadata and controls
52 lines (45 loc) · 1.3 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
import "@tanstack/react-start/server-only";
import { drizzleAdapter } from "@better-auth/drizzle-adapter";
import { betterAuth } from "better-auth/minimal";
import { tanstackStartCookies } from "better-auth/tanstack-start";
import { env } from "@/env/server";
import { db } from "@/lib/db";
import * as schema from "@/lib/db/schema";
export const auth = betterAuth({
baseURL: env.VITE_BASE_URL,
telemetry: {
enabled: false,
},
database: drizzleAdapter(db, {
provider: "pg",
schema,
}),
// https://www.better-auth.com/docs/integrations/tanstack#usage-tips
plugins: [tanstackStartCookies()],
// https://www.better-auth.com/docs/concepts/session-management#session-caching
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60, // 5 minutes
},
},
// https://www.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://www.better-auth.com/docs/authentication/email-password
emailAndPassword: {
enabled: true,
},
experimental: {
// https://www.better-auth.com/docs/adapters/drizzle#joins-experimental
joins: true,
},
});