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

@chatpack/adapter-prisma

v0.1.0

Published

Prisma ORM (PostgreSQL) storage adapter for Chatpack

Readme

@chatpack/adapter-prisma

First-party Chatpack storage adapter for Prisma ORM 7 and PostgreSQL. It implements conversations, messages, search, reactions, mentions, replies, forwarding, read state, invites, public channels, and moderation.

Install

pnpm add @chatpack/core @chatpack/adapter-prisma @prisma/client @prisma/adapter-pg pg
pnpm add -D prisma

Prisma ORM 7 requires Node.js 20.19 or newer. Prisma 8 is the current Prisma release, but it uses a different contract/query client and is not supported by this adapter. Prisma 7 is the supported generated-client API.

Schema and migrations

Copy the models from prisma/schema.prisma into your application schema. Keep your own datasource and generator configuration. With Prisma 7, put the database URL in prisma.config.ts:

import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: { path: "prisma/migrations" },
  datasource: { url: env("DATABASE_URL") },
});

Copy this package's prisma/migrations/0001_chatpack/migration.sql into your application migrations directory, followed by prisma/migrations/0002_thread_replies/migration.sql. Existing databases need the second migration before updating the adapter. Then run prisma format, prisma validate, prisma migrate deploy, and prisma generate. The migration is PostgreSQL DDL and creates twelve chatpack_* tables. It never creates or references an application-owned users table. For an existing Chatpack database, inspect the current schema and write an explicit migration; CREATE TABLE IF NOT EXISTS does not alter incompatible tables.

Set threads: { enabled: true } on the Chatpack installation to allow thread replies.

Server-only setup

Create the Prisma client in trusted server code. The adapter accepts that caller-created client and never reads credentials, creates a pool, or owns the client lifecycle.

import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "./generated/client/client.js";
import { chatpack } from "@chatpack/core";
import { prismaAdapter } from "@chatpack/adapter-prisma";

const prisma = new PrismaClient({
  adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }),
});

export const chat = chatpack({
  storage: prismaAdapter(prisma),
  auth: resolveAppUser,
});

Never import this adapter, Prisma client, connection string, or database credentials into browser code. Generate the client from the consumer's schema; this package does not bundle a replacement generated client.

Correctness boundary

Conversation pair uniqueness and message (conversation_id, seq) uniqueness are database-enforced. Group creation and message sequence allocation use interactive transactions. Sequence allocation increments the conversation row under PostgreSQL row locking at ReadCommitted, then inserts the message in the same transaction. Serializable transactions retry bounded P2034 and 40001 conflicts. Invite use caps use one parameterized conditional UPDATE ... RETURNING; active bans serialize with a PostgreSQL transaction advisory lock because Prisma schemas cannot express a time-dependent partial unique index.

Run backfillMessageSearchTokens(prisma) after importing messages from a database that predates the search-token table or has incomplete tokens.

Support

Verified support is Prisma ORM 7.10.0 with @prisma/adapter-pg 7.10.0 and PostgreSQL 16. The adapter does not claim MySQL, SQLite, CockroachDB, SQL Server, MongoDB, Prisma 8, Accelerate, serverless drivers, edge runtimes, or other Prisma versions. Test those combinations separately before use.