pg-browser-proxy v0.1.0 is a lightweight WebSocket-TCP proxy that allows standard PostgreSQL clients (psql, pgAdmin, Drizzle Studio, Prisma Studio) to connect to a Postgres database running in the browser (e.g., PGlite). It creates a TCP server that forwards PostgreSQL wire protocol messages to the browser via WebSocket. Unlike direct in-browser database tools, it enables existing CLI and GUI tools to manage browser-based databases without changes. The proxy is designed for development and testing, with support for custom ports and single-browser-connection limitation.
npm install pg-browser-proxyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a PGlite in-browser database and connects it to the proxy, enabling external PostgreSQL clients to interact with it.
Ensure only a single browser tab connects the proxy; multiple connections will cause issues.
Use db.execProtocolRaw() as shown in the example; standard query methods may not work.
Use -t flag to specify an alternative port: bunx pg-browser-proxy -t 5433
Use -w flag to specify an unprivileged port: bunx pg-browser-proxy -w 8080
Run proxy with a different port: bunx pg-browser-proxy -w 8080
Use named import: import { connectProxy } from 'pg-browser-proxy'Use PGliteWorker from '@electric-sql/pglite/worker' and create worker with correct URL
Start proxy with bunx pg-browser-proxy and ensure tcpPort matches client connection string