npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bolkauth/adapter-drizzle

v0.1.2

Published

Drizzle ORM adapter for BolkAuth

Readme

@bolkauth/adapter-drizzle

npm version License: MIT

Official Drizzle ORM PostgreSQL adapter for BolkAuth. Provides pre-built schema definitions, session token hashing, metadata storage, and seamless integration with Drizzle Kit.

Features

  • 🗄️ PostgreSQL Support: Optimized for PostgreSQL via Drizzle ORM (drizzle-orm/pg-core).
  • 🔐 Token Hashing: Built-in SHA-256 token hashing for sessions and verification tokens.
  • 📦 Exported Table Schemas: Pre-defined PostgreSQL tables (authUsers, authSessions, authAccounts, authVerificationTokens, authUserMetadata).
  • Connection Pooling: Native compatibility with pg, postgres.js, @neondatabase/serverless, and @planetscale/database.
  • 🛠️ Drizzle Kit Ready: Easily run schema migrations and pushes.

Installation

npm install @bolkauth/adapter-drizzle @bolkauth/core drizzle-orm pg
npm install -D drizzle-kit @types/pg
# or
pnpm add @bolkauth/adapter-drizzle @bolkauth/core drizzle-orm pg
pnpm add -D drizzle-kit @types/pg

Database Schema Setup

Export BolkAuth table definitions in your Drizzle schema file (e.g. db/schema.ts):

// db/schema.ts
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
export {
  authUsers,
  authAccounts,
  authSessions,
  authVerificationTokens,
  authUserMetadata,
} from "@bolkauth/adapter-drizzle";

// Optionally add your application tables here
export const posts = pgTable("posts", {
  id: text("id").primaryKey(),
  title: text("title").notNull(),
  authorId: text("author_id").notNull(),
});

Table Definitions Reference

BolkAuth manages 5 PostgreSQL tables in your database:

| Exported Table | Database Table Name | Key Fields | Description | | :--- | :--- | :--- | :--- | | authUsers | bolkauth_users | id, email, password, emailVerified, name, image | Stores core user identities and auth credentials. | | authAccounts | bolkauth_accounts | userId, provider, providerAccountId, access_token | Stores linked OAuth provider credentials. | | authSessions | bolkauth_sessions | sessionToken (SHA-256), userId, expires | Tracks active authenticated sessions. | | authVerificationTokens | bolkauth_verification_tokens | identifier, token (SHA-256), expires | Password reset and email magic link verification tokens. | | authUserMetadata | bolkauth_user_metadata | id, userId, key, value (JSONB) | Key-value store for user metadata & custom settings. |


Adapter Initialization & Connection Pooling

Set up your PostgreSQL database connection pool and initialize createDrizzleAdapter:

// db/index.ts
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import { createDrizzleAdapter } from "@bolkauth/adapter-drizzle";
import { createBolkAuth } from "@bolkauth/core";
import * as schema from "./schema";

// 1. Connection pooling with pg.Pool
const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
  max: 10,
  idleTimeoutMillis: 30000,
});

export const db = drizzle(pool, { schema });

// 2. Initialize BolkAuth with Drizzle Adapter
export const auth = createBolkAuth({
  adapter: createDrizzleAdapter(db),
  secret: process.env.BOLKAUTH_SECRET!,
});

Migrations & Schema Push

1. Configure drizzle.config.ts

// drizzle.config.ts
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  schema: "./db/schema.ts",
  out: "./drizzle",
  dialect: "postgresql",
  dbCredentials: {
    url: process.env.DATABASE_URL!,
  },
});

2. Generate and Apply Migrations

# Push schema directly to database (development)
npx drizzle-kit push

# Or generate migration files for production
npx drizzle-kit generate
npx drizzle-kit migrate

API Reference

createDrizzleAdapter(db: DrizzleDatabase)

Factory function returning a full BolkAuthAdapter instance.

Adapter Methods Implemented:

  • Users: createUser, findUserById, findUserByEmail, updateUser, deleteUser
  • Sessions: createSession, findSessionByToken, updateSession, deleteSession, deleteUserSessions
  • Accounts: createAccount, findAccountByProvider
  • Verification Tokens: createVerificationToken, findVerificationToken, deleteVerificationToken
  • Metadata: getUserMetadata, updateUserMetadata

License

MIT © BolkAuth