Skip to content

Commit 9762cbd

Browse files
committed
feat: setup auth lib with better-auth
1 parent 878f176 commit 9762cbd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

.dev.vars.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ CLOUDFLARE_API_TOKEN=your-api-token-here
1212
# Authentication
1313
BETTER_AUTH_SECRET=your-better-auth-secret # see https://www.better-auth.com/docs/installation
1414
BETTER_AUTH_URL=http://localhost:3000 # Base URL of your app
15+
16+
# Google Auth : see https://www.better-auth.com/docs/authentication/google
17+
GOOGLE_CLIENT_ID=your-google-client-id
18+
GOOGLE_CLIENT_SECRET=your-google-client-secret

src/lib/auth.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** biome-ignore-all lint/style/noNonNullAssertion: <we will make sure it's not null> */
2+
import { betterAuth } from "better-auth";
3+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
4+
import { getDb as db } from "./db";
5+
6+
export const auth = betterAuth({
7+
database: drizzleAdapter(db, {
8+
provider: "sqlite",
9+
}),
10+
emailAndPassword: {
11+
enabled: true,
12+
},
13+
socialProviders: {
14+
google: {
15+
enabled: true,
16+
clientId: process.env.GOOGLE_CLIENT_ID!,
17+
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
18+
},
19+
},
20+
});

0 commit comments

Comments
 (0)