
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
better-auth-drizzle-adapter
Advanced tools
Drizzle ORM v1 adapter for Better Auth with relations v2 support.
Drizzle ORM v1 adapter for Better Auth with relations v2 support.
Vendored from better-auth/better-auth#9489.
pnpm add better-auth-drizzle-adapter
import { betterAuth } from 'better-auth'
import { drizzleAdapter } from 'better-auth-drizzle-adapter'
import { drizzle } from 'drizzle-orm/d1'
import * as schema from './schema'
const db = drizzle(env.DB, { schema })
export const auth = betterAuth({
database: drizzleAdapter(db, { provider: 'sqlite' }),
// ...
})
Drizzle owns the encoding for every field Better Auth types as string[],
number[] or json, so those columns must be declared as json mode. This is
what createSchema generates:
scopes: text('scopes', { mode: 'json' }).$type<string[]>() // sqlite, mysql
scopes: text('scopes').array() // pg
string[] and number[] are unchanged: supportsArrays was already true,
so the stored bytes and the values you read back are identical. Nothing to do.
Only json fields changed. Before 1.2.0, supportsJSON was provider-based, so
on SQLite and MySQL Better Auth stringified them and the json-mode column
stringified them again, storing "{\"a\":1}". Better Auth read that back
correctly, so the bug was invisible unless you queried the column directly.
Rows written before 1.2.0 now decode to a string instead of an object. One
idempotent statement unwraps them, skipping NULLs and rows that are already
correct:
-- SQLite
UPDATE oauth_client
SET metadata = json_extract(metadata, '$')
WHERE metadata IS NOT NULL AND json_type(metadata) = 'text';
-- MySQL
UPDATE oauth_client
SET metadata = JSON_UNQUOTE(metadata)
WHERE metadata IS NOT NULL AND JSON_TYPE(metadata) = 'STRING';
Better Auth core (user, session, account, verification) has no json
fields, so a plugin-free install has nothing to migrate. Run the statement once
per json column your plugins declare; with oauthProvider that is only
oauth_client.metadata.
better-auth >= 1.6.0drizzle-orm >= 1.0.0-beta.1MIT
FAQs
Drizzle ORM v1 adapter for Better Auth with relations v2 support.
We found that better-auth-drizzle-adapter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.