Authentication
Auth is powered by Better Auth with a Prisma adapter. Configuration lives in ; routes and provider metadata are centralized in .
What's included
- Email + password sign up / sign in
- OAuth (Google, GitHub) — buttons appear only when credentials are configured
- Password reset and email verification (dev emails print to the server console)
- Session-based protected routes
Required setup
Set BETTER_AUTH_SECRET in .env:
That's all you need for email/password auth.
OAuth (optional)
A provider turns on automatically when both its id and secret are present.
- Create OAuth credentials in the .
- Authorized redirect URI:
http://localhost:3000/api/auth/callback/google. - Set
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET.
GitHub
- Create an OAuth App in .
- Authorization callback URL:
http://localhost:3000/api/auth/callback/github. - Set
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRET.
In production, swap localhost:3000 for your domain.
Protecting routes
Use the server helpers in :
Middleware does a fast optimistic cookie check; requireAuth() is the
authoritative guard.
New-user provisioning
When a user is created, puts them on the Free plan and grants their starter credits. Customize the welcome experience there.
Emails
Transactional emails are stubbed in and print to the console in development. Swap the implementation for a real provider (Resend, Postmark, Nodemailer…) — the call sites don't change.