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-prisma

v0.1.2

Published

Prisma ORM adapter for BolkAuth

Readme

@bolkauth/adapter-prisma

npm version License: MIT

Official Prisma ORM adapter for BolkAuth. Compatible with PostgreSQL, MySQL, SQLite, and CockroachDB via Prisma Client.

Features

  • 💎 Prisma Client Support: Clean integration with standard @prisma/client.
  • 🔐 Token Security: SHA-256 token hashing for sessions and verification tokens.
  • 📐 Complete Data Models: Standardized Prisma models (AuthUser, AuthSession, AuthAccount, AuthVerificationToken, AuthUserMetadata).
  • 🔄 Cascade Deletions: Automatic foreign key cascade cleanup on user deletion.
  • 📦 Exported Schema Reference: Exported schemaPath constant for programmatic schema loading.

Installation

npm install @bolkauth/adapter-prisma @bolkauth/core @prisma/client
npm install -D prisma
# or
pnpm add @bolkauth/adapter-prisma @bolkauth/core @prisma/client
pnpm add -D prisma

Prisma Schema Configuration

Add the BolkAuth models to your prisma/schema.prisma file:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model AuthUser {
  id            String    @id @default(cuid())
  email         String    @unique
  emailVerified DateTime?
  name          String?
  image         String?
  password      String?
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt

  sessions      AuthSession[]
  accounts      AuthAccount[]
  metadata      AuthUserMetadata[]
}

model AuthSession {
  id        String   @id @default(cuid())
  userId    String
  expiresAt DateTime
  token     String   @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  user      AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model AuthAccount {
  id                String   @id @default(cuid())
  userId            String
  provider          String
  providerAccountId String
  accessToken       String?
  refreshToken      String?
  expiresAt         Int?
  createdAt         DateTime @default(now())
  updatedAt         DateTime @updatedAt

  user              AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model AuthVerificationToken {
  identifier String
  token      String
  expiresAt  DateTime
  createdAt  DateTime @default(now())

  @@unique([identifier, token])
}

model AuthUserMetadata {
  userId    String
  key       String
  value     String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  user      AuthUser @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@id([userId, key])
}

Migrations & Client Generation

Run Prisma CLI commands to generate the client and apply migrations:

# Generate Prisma Client
npx prisma generate

# Apply migrations in development
npx prisma migrate dev --name init_bolkauth

# Deploy migrations in production / CI
npx prisma migrate deploy

Adapter Setup

Initialize the createPrismaAdapter with your PrismaClient instance:

// lib/auth.ts
import { PrismaClient } from "@prisma/client";
import { createPrismaAdapter } from "@bolkauth/adapter-prisma";
import { createBolkAuth } from "@bolkauth/core";

const prisma = new PrismaClient();

export const auth = createBolkAuth({
  adapter: createPrismaAdapter(prisma),
  secret: process.env.BOLKAUTH_SECRET!,
});

API Reference

createPrismaAdapter(db: PrismaClient)

Accepts an initialized PrismaClient instance and exposes full CRUD adapter methods for BolkAuth:

  • createUser(user) / findUserById(id) / findUserByEmail(email) / updateUser(id, data) / deleteUser(id)
  • createSession(session) / findSessionByToken(token) / updateSession(id, data) / deleteSession(id) / deleteUserSessions(userId)
  • createAccount(account) / findAccountByProvider(provider, providerAccountId)
  • createVerificationToken(token) / findVerificationToken(identifier, token) / deleteVerificationToken(identifier, token)
  • getUserMetadata(userId, key) / updateUserMetadata(userId, key, value)

Helper Export: schemaPath

import { schemaPath } from "@bolkauth/adapter-prisma";
console.log(schemaPath); // Path to default schema.prisma provided by adapter

License

MIT © BolkAuth