Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

README.md.ejs

32 lines807 Bytes

1## Setting up Better Auth
2​
31. Generate and set the `BETTER_AUTH_SECRET` environment variable in your `.env.local`:
4​
5 ```bash
6 <%- getPackageManagerExecuteScript('@better-auth/cli', ['secret']) %>
7 ```
8​
92. Visit the [Better Auth documentation](https://www.better-auth.com) to unlock the full potential of authentication in your app.
10​
11### Adding a Database (Optional)
12​
13Better Auth can work in stateless mode, but to persist user data, add a database:
14​
15```typescript
16// src/lib/auth.ts
17import { betterAuth } from "better-auth";
18import { Pool } from "pg";
19​
20export const auth = betterAuth({
21 database: new Pool({
22 connectionString: process.env.DATABASE_URL,
23 }),
24 // ... rest of config
25});
26```
27​
28Then run migrations:
29​
30```bash
31<%- getPackageManagerExecuteScript('@better-auth/cli', ['migrate']) %>
32```