MySQL
Source:
packages/better-auth/src/MySQL.tsKind: Layer · Provides:BetterAuth.Database· Peer dependencies:mysql2
Generic TCP MySQL database layer for Better Auth, from a connection string.
Works with PlanetScale MySQL, Cloudflare Hyperdrive MySQL origins, AWS
RDS MySQL, or any literal URL. One mysql2 pool per execution, closed
when the event settles.
Connecting to PlanetScale MySQL
Section titled “Connecting to PlanetScale MySQL”PlanetScale requires TLS — pass it in the URL’s ssl query parameter
(mysql2 parses it as JSON).
import { BetterAuth } from "@alchemy.run/better-auth";import { MySQL } from "@alchemy.run/better-auth/MySQL";
const password = yield* Planetscale.MySQLPassword("auth-db", { database, role: "admin",});const url = `mysql://${password.username}:...@${password.host}/${database.name}` + `?ssl=${encodeURIComponent('{"rejectUnauthorized":true}')}`;
Effect.gen(function* () { const auth = yield* BetterAuth({ emailAndPassword: { enabled: true } }); return { fetch: ... };}).pipe(Effect.provide(MySQL(url)))