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

v0.0.0

Published

Supabase storage adapter for Chatpack - server-side Postgres persistence

Readme

@chatpack/adapter-supabase

Server-side Supabase storage for Chatpack. It uses the Supabase PostgREST client for reads and ordinary writes, and PostgreSQL RPCs for operations that need one transaction or one row lock.

Install

pnpm add @chatpack/core @chatpack/adapter-supabase @supabase/supabase-js

Apply supabase/migrations/0001_chatpack.sql with the Supabase CLI:

supabase link --project-ref "$SUPABASE_PROJECT_REF"
supabase db push

Or run the SQL file in Supabase SQL Editor. Run it before starting Chatpack. The adapter does not apply migrations automatically. If the migration is kept inside a package workspace, run the CLI from that directory or copy the file into the Supabase project's migration directory first.

Server-only setup

Create one privileged client in server code. Do not use a browser client, do not expose the service-role/server-secret key, and do not bundle this package into client code. Disable session persistence so a user session cannot replace the privileged client credentials.

import { createClient } from "@supabase/supabase-js";
import { chatpack } from "@chatpack/core";
import { supabaseAdapter } from "@chatpack/adapter-supabase";

const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!, {
  auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false },
});

export const chat = chatpack({
  storage: supabaseAdapter(supabase),
  auth: resolveAppUser,
});

The migration enables Row Level Security on every Chatpack table and creates no public policies. Supabase service-role keys bypass RLS, so keep them only in trusted server infrastructure. The migration also grants table and RPC access only to service_role, which is required for server-side PostgREST access on new Supabase projects. Chatpack core still owns application permission checks; RLS is a second boundary against accidental public table access.

Capabilities

This adapter implements the complete current StorageAdapter contract, participant-scoped search, invite links and join requests, public channels, and durable moderation. Direct conversation creation, group creation, message sequence allocation, message search-token maintenance, mention replacement, invite consumption, and active-ban creation use migration-provided RPCs.

The default tests are deterministic and do not require a hosted Supabase project. An external integration suite can use SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY against an isolated test project. Never point such a suite at production data.

Source layout

  • src/index.ts contains the public adapter and StorageAdapter method wiring.
  • src/types.ts contains table names, RPC names, and database row contracts.
  • src/utils.ts contains conversion-safe dates, cursors, IDs, token rows, and Supabase error guards.
  • src/converters.ts maps database rows to Chatpack domain values.
  • supabase/migrations/0001_chatpack.sql owns schema, indexes, RLS, and the transaction-sensitive RPCs.

The exported API is intentionally small: supabaseAdapter(client, options?) and SupabaseAdapterOptions. The remaining modules are implementation details.