Skip to content

Better Auth

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.

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

Use email/password, GitHub, Google, Microsoft, or custom OAuth. Each guide covers registration, configuration, and browser sign-in.

Keep the Auth service and change the database layer. The database guides cover D1, Hyperdrive, Neon, Aurora, Postgres, MySQL, Drizzle, SQLite, and memory.

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.

The 1.6 → 1.7.5 upgrade guide separates package and API changes from manual data preparation. Migrations explains what deployment applies automatically.