Registry / database / better-auth-typeorm-adapter

better-auth-typeorm-adapter

JSON →
library1.1.4jsnpmunverified

A production-ready TypeORM adapter for Better Auth, the modern authentication library for TypeScript. Version 1.1.4 supports all Better Auth operations (CRUD, queries) with full type safety and multi-database compatibility (PostgreSQL, MySQL, SQLite). Requires peer dependencies better-auth ^1.3.0 and typeorm ^0.3.0. Zero runtime dependencies beyond peers, ships TypeScript types, includes debug mode for logging. Actively maintained with community contributions.

npm install better-auth-typeorm-adapter
INSTALL
IMPORT
SIG · BETTER-AUTH-TYPEOR
B
better-auth-typeorm-adapter
databasejavascriptv1.1.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TypeORMAdapter
import { TypeORMAdapter } from 'better-auth-typeorm-adapter'
import TypeORMAdapter from 'better-auth-typeorm-adapter'
This is a named export, not default. CJS users: const { TypeORMAdapter } = require('better-auth-typeorm-adapter').
default
import { TypeORMAdapter } from 'better-auth-typeorm-adapter'
const adapter = require('better-auth-typeorm-adapter')
No default export exists. Always destructure the named export.
type UserEntity
import type { UserEntity } from 'better-auth-typeorm-adapter/entities'
import { UserEntity } from 'better-auth-typeorm-adapter/entities'
TypeScript declaration files for entities are re-exported from subpath 'entities'. Use type import for compile-time only.
TypeORMAdapterOptions
import { TypeORMAdapter } from 'better-auth-typeorm-adapter' const options: import('better-auth-typeorm-adapter').TypeORMAdapterOptions = { entities: [User, Account, Session, Verification] }
import { TypeORMAdapterOptions } from 'better-auth-typeorm-adapter'
Adapter options are not exported directly; infer from type parameter or use typeof.

Initialize TypeORM DataSource, define entities, create adapter, and pass to betterAuth.

import { DataSource } from 'typeorm'; import { TypeORMAdapter } from 'better-auth-typeorm-adapter'; import { betterAuth } from 'better-auth'; import { User } from './user.entity'; import { Account } from './account.entity'; import { Session } from './session.entity'; import { Verification } from './verification.entity'; const dataSource = new DataSource({ type: 'postgres', url: process.env.DATABASE_URL ?? 'postgres://localhost:5432/mydb', entities: [User, Account, Session, Verification], synchronize: true, }); await dataSource.initialize(); const auth = betterAuth({ database: new TypeORMAdapter({ entities: { user: User, account: Account, session: Session, verification: Verification, }, dataSource, }), });
Debug
Known issues
gotchaEntity schema must match Better Auth's expected fields exactly. Missing columns like 'emailVerified' (camelCase) or wrong column types cause runtime errors.
fix
Use the provided entity examples from the README and ensure column names match the default schema (email_verified, account_id, etc.).
affects: >=1.0.0
deprecatedAdapter v0.x used a different constructor signature. Version 1.x changed to receive a single options object.
fix
Upgrade to v1.1.4 and pass { entities, dataSource } object instead of separate arguments.
affects: <1.0.0
breakingTypeORMAdapter no longer accepts raw entity classes in an array; requires a mapping object with keys 'user', 'account', 'session', 'verification'.
fix
Wrap entities in an object: new TypeORMAdapter({ entities: { user: User, ... }, dataSource }).
affects: >=1.0.0
gotchaAll entity IDs must be UUIDs generated by TypeORM (e.g., @PrimaryGeneratedColumn('uuid')). Integer IDs will not satisfy Better Auth's internal checks.
fix
Use @PrimaryGeneratedColumn('uuid') on every entity's id column.
affects: >=1.0.0
gotchaDebug mode logs all adapter operations to stdout. Do not enable in production without a logger filter.
fix
Set { debug: false } in options; default is false.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Missing peer dependency (typeorm or better-auth) or incorrect import path.
fix
Install peer deps: npm install better-auth@^1.3.0 typeorm@^0.3.0
QueryFailedError: column "email_verified" does not exist
Entity column name mismatch: TypeORM expects column names in snake_case (default naming strategy) but Better Auth provides camelCase.
fix
Add explicit @Column({ name: 'email_verified' }) decorator with correct 'name' property.
Cannot find module 'better-auth-typeorm-adapter/entities'
Subpath exports not resolved; likely an old version of the adapter or incorrect path.
fix
Update to v1.1.4 and use import { UserEntity } from 'better-auth-typeorm-adapter' (no /entities subpath) or check type definitions.
AuthError: Invalid adapter configuration: missing 'dataSource'
TypeORMAdapter constructed without the 'dataSource' property in the options object.
fix
Pass { entities: {...}, dataSource: yourDataSource } as single argument.
Upgrade
Version history
1.1.4latest on npm
Audit
Dependencies
better-authrequiredPeer dependency: core authentication library this adapter implements interfaces for.
typeormrequiredPeer dependency: ORM used to define entities and perform database operations.
Agent activity
38 hits · last 30 days
node
30
OpenAI (training)
2
Resources
better-auth-typeorm-adapter — npm install better-auth-typeorm-adapter · libregistry