sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ better-auth/ index.mdx

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.

PartBuild
1. Create an Auth serviceInstall the module and provide a database layer
2. Mount the HTTP APIServe authentication and application routes
3. Build sign-inSign up, sign in, read sessions, and sign out
4. Protect API endpointsProvide the current user through Effect middleware
5. Add GitHub sign-inRegister an OAuth app and bind its credentials
6. Deploy and verifyConfigure 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.