Skip to content

Drizzle

Source: packages/better-auth/src/Drizzle.ts Kind: Layer · Provides: BetterAuth.Database · Peer dependencies: drizzle-orm

Use an existing Drizzle database as Better Auth’s storage via better-auth’s official drizzleAdapter.

Accepts a plain drizzle instance, or an Effect resolving to one for databases that only materialize at runtime. NOTE: alchemy’s own Drizzle.Postgres/Drizzle.D1 chainable proxies yield Effects rather than thenables and cannot back the (promise-based) adapter — pass the raw drizzle(...) instance instead.

Schema management is yours: this layer has no automatic migration support (npx @better-auth/cli generate + your drizzle-kit flow own the tables).

import { BetterAuth } from "@alchemy.run/better-auth";
import { Drizzle } from "@alchemy.run/better-auth/Drizzle";
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from "./auth-schema.ts"; // npx @better-auth/cli generate
const db = drizzle(pool, { schema });
Effect.gen(function* () {
const auth = yield* BetterAuth({ emailAndPassword: { enabled: true } });
// ...
}).pipe(Effect.provide(Drizzle(db, { provider: "pg", schema })))