⚡ BolkAuth

Database Drivers

BolkAuth provides zero-boilerplate driver helper packages (@bolkauth/driver-pg, @bolkauth/driver-mysql2, and @bolkauth/driver-mongodb) that handle connection pool management, production performance tuning, and schema adapter instantiation in a single call.

Available Drivers

PackageDatabaseUnderlying DriverProduction Default
@bolkauth/driver-pgPostgreSQLpg + Drizzle ORMPool max: 20, idleTimeout: 30s
@bolkauth/driver-mysql2MySQL / MariaDBmysql2 + Drizzle ORMPool connectionLimit: 10, enableKeepAlive: true
@bolkauth/driver-mongodbMongoDBmongodb Native DriverAuto autoEnsureIndexes: false in production

PostgreSQL Driver (@bolkauth/driver-pg)

pnpm add @bolkauth/driver-pg @bolkauth/adapter-drizzle drizzle-orm pg
import { createPgDriver } from "@bolkauth/driver-pg";
import { createBolkAuth } from "@bolkauth/core";
 
const { pool, db, adapter } = createPgDriver({
  connectionString: process.env.DATABASE_URL!,
  max: 20, // production pool limit
});
 
export const auth = createBolkAuth({
  adapter,
  secret: process.env.BOLKAUTH_SECRET!,
});

MySQL Driver (@bolkauth/driver-mysql2)

pnpm add @bolkauth/driver-mysql2 @bolkauth/adapter-drizzle drizzle-orm mysql2
import { createMysql2Driver } from "@bolkauth/driver-mysql2";
import { createBolkAuth } from "@bolkauth/core";
 
const { connection, db, adapter } = createMysql2Driver({
  uri: process.env.MYSQL_URL!,
  connectionLimit: 10,
  enableKeepAlive: true,
});
 
export const auth = createBolkAuth({
  adapter,
  secret: process.env.BOLKAUTH_SECRET!,
});

MongoDB Driver (@bolkauth/driver-mongodb)

pnpm add @bolkauth/driver-mongodb @bolkauth/adapter-mongodb mongodb
import { createMongoDriver } from "@bolkauth/driver-mongodb";
import { createBolkAuth } from "@bolkauth/core";
 
const { client, db, adapter } = await createMongoDriver({
  uri: process.env.MONGODB_URI!,
  dbName: "my_auth_db",
});
 
export const auth = createBolkAuth({
  adapter,
  secret: process.env.BOLKAUTH_SECRET!,
});

On this page