Registry /
database / better-auth-typeorm-adapter
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
muslnode 18–226 runs
build_error
glibcnode 18–226 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,
}),
});
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.
fixInstall 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.
fixAdd 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.
fixUpdate 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.
fixPass { entities: {...}, dataSource: yourDataSource } as single argument. Audit
Dependencies
better-authrequiredPeer dependency: core authentication library this adapter implements interfaces for.
typeormrequiredPeer dependency: ORM used to define entities and perform database operations.