Zero-dependency polyfill for PostgreSQL LISTEN/NOTIFY in Bun, currently at v0.1.1 with active development. Since Bun's built-in sql driver does not implement LISTEN/NOTIFY, this library provides a temporary, drop-in replacement that mirrors Bun.sql's connection configuration (env vars, URL, inline options) and adds SCRAM-SHA-256 authentication (RFC 7677), exponential backoff reconnection with automatic re-LISTEN, and TLS support (sslmode=require/verify-ca/verify-full). Designed to be removed once Bun native support lands (tracking issue oven-sh/bun#18214). Unlike alternatives like pg or postgres.js, it has zero runtime dependencies and focuses solely on the listen/notify pub/sub pattern for Bun >= 1.2 and Postgres >= 13.
npm install bun-pg-listenNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic connect, listen with callback, notify, and cleanup using the PgListener class.
Monitor Bun releases and remove dependency when native support lands.
Use Bun 1.2+ and Postgres 13+, or ensure server uses SCRAM-SHA-256.
Use object notation: new PgListener({ hostname: '...', ... })Change postgresql.conf to use scram-sha-256 or update pg_hba.conf accordingly.
Provide CA cert via tls option: new PgListener(url, { tls: { ca: '...' } })Ensure password is properly escaped or use alphanumeric characters. The library expects a UTF-8 string.
Enable reconnection callbacks (onReconnect) and ensure server supports SCRAM-SHA-256.
Set one of: POSTGRES_URL, DATABASE_URL, PGURL, or pass config to PgListener constructor.
Pass CA certificate via tls option: { tls: { ca: await Bun.file('ca.pem').text() } }