Build sign-in and protected APIs with Better Auth, using ordinary Effect services and layers. Alchemy supplies database bindings, a stable signing secret, and supported schema migrations.
Start the tutorial
import { BetterAuth } from "@alchemy.run/better-auth";
const makeAuth = BetterAuth({
basePath: "/api/auth",
emailAndPassword: { enabled: true },
}); The six-part tutorial turns this into a running application with browser sign-in, session middleware, and GitHub authentication.
| Part | Build |
|---|---|
| 1. Create an Auth service | Install the module and provide a database layer |
| 2. Mount the HTTP API | Serve authentication and application routes |
| 3. Build sign-in | Sign up, sign in, read sessions, and sign out |
| 4. Protect API endpoints | Provide the current user through Effect middleware |
| 5. Add GitHub sign-in | Register an OAuth app and bind its credentials |
| 6. Deploy and verify | Configure production callbacks and check persistence |
Choose a sign-in provider
Use email/password, GitHub, Google, Microsoft, or custom OAuth. Each guide covers registration, configuration, and browser sign-in.
Choose a database
Keep the Auth service and change the database layer. The database guides cover D1, Hyperdrive, Neon, Aurora, Postgres, MySQL, Drizzle, SQLite, and memory.
Extend the application
Use Config and secrets for deployment bindings, HTTP API middleware for Effect handlers, and secondary storage for custom storage layers.
For Better Auth's authentication features and options, see the Better Auth documentation.
Upgrade an existing installation
The 1.6 → 1.7.5 upgrade guide separates package and API changes from manual data preparation. Migrations explains what deployment applies automatically.