Skip to main content

Database Adapter

Package: @nauth-toolkit/storage-database Type: Storage Adapter (Production)

TypeORM-based storage for transient authentication state.

npm install @nauth-toolkit/storage-database
note

Requires database package for entities. See Database Packages.

Usage

import { DatabaseStorageAdapter } from '@nauth-toolkit/storage-database';
import { getNAuthTransientStorageEntities } from '@nauth-toolkit/database-typeorm-postgres';

// Include transient storage entities in TypeORM
TypeOrmModule.forRoot({
entities: [
...getNAuthTransientStorageEntities(),
// your entities...
],
})

AuthModule.forRoot({
storageAdapter: new DatabaseStorageAdapter(),
})

When to Use

  • Single-database architecture (no separate Redis)
  • Lower infrastructure complexity
  • Acceptable performance for moderate load

Trade-offs vs Redis

AspectDatabaseRedis
PerformanceGoodExcellent
InfrastructureExisting DBAdditional service
ScalingVerticalHorizontal