{"id":43539,"library":"pg-browser-proxy","title":"PG Browser Proxy","description":"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.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/f0rr0/pg-browser-proxy","tags":["javascript","postgresql","postgres","browser","websocket","proxy","pglite","drizzle","drizzle-kit"],"install":[{"cmd":"npm install pg-browser-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add pg-browser-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-browser-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to create the browser-based Postgres instance that the proxy connects to","package":"@electric-sql/pglite","optional":false}],"imports":[{"note":"Default export is not available; connectProxy is a named export.","wrong":"import connectProxy from 'pg-browser-proxy'","symbol":"connectProxy","correct":"import { connectProxy } from 'pg-browser-proxy'"},{"note":"The package is ESM-only; CommonJS require will not work. Use dynamic import() if needed.","wrong":"const { runProxy } = require('pg-browser-proxy')","symbol":"runProxy","correct":"import { runProxy } from 'pg-browser-proxy'"},{"note":"Options is a type export; import it with `type` to avoid runtime errors.","wrong":"import { Options } from 'pg-browser-proxy'","symbol":"Type","correct":"import type { Options } from 'pg-browser-proxy'"}],"quickstart":{"code":"import { connectProxy } from 'pg-browser-proxy';\nimport { PGliteWorker } from '@electric-sql/pglite/worker';\n\nconst db = await PGliteWorker.create(\n  new Worker(new URL('./worker', import.meta.url), { type: 'module' }),\n);\n\nconnectProxy((message) => db.execProtocolRaw(message), {\n  tcpPort: 5432,\n  wsPort: 443,\n});\n\n// Then connect with psql: psql -h localhost -p 5432 -U postgres","lang":"typescript","description":"Creates a PGlite in-browser database and connects it to the proxy, enabling external PostgreSQL clients to interact with it."},"warnings":[{"fix":"Ensure only a single browser tab connects the proxy; multiple connections will cause issues.","message":"Only one browser connection is allowed at a time","severity":"gotcha","affected_versions":"<=0.1.0"},{"fix":"Use db.execProtocolRaw() as shown in the example; standard query methods may not work.","message":"The database must handle raw PostgreSQL wire protocol messages for connectProxy to work","severity":"gotcha","affected_versions":"<=0.1.0"},{"fix":"Use -t flag to specify an alternative port: bunx pg-browser-proxy -t 5433","message":"TCP port 5432 is default and may conflict with a local PostgreSQL installation","severity":"gotcha","affected_versions":"<=0.1.0"},{"fix":"Use -w flag to specify an unprivileged port: bunx pg-browser-proxy -w 8080","message":"WebSocket port defaults to 443, which requires root/admin privileges on Unix systems","severity":"gotcha","affected_versions":"<=0.1.0"}],"env_vars":null,"search_vec":"'allow':17 'base':73 'browser':2,6,36,52,59,72,93,99 'browser-bas':71 'chang':76 'cli':65 'client':20 'connect':28,94 'creat':40 'custom':88 'databas':32,60,74 'design':80 'develop':82 'direct':56 'drizzl':23,103,105 'drizzle-kit':104 'e.g':37 'enabl':63 'exist':64 'forward':45 'gui':67 'in-brows':57 'javascript':96 'kit':106 'lightweight':11 'limit':95 'manag':70 'messag':49 'pg':1,5 'pg-browser-proxi':4 'pgadmin':22 'pglite':38,102 'port':89 'postgr':31,98 'postgresql':19,46,97 'prisma':25 'protocol':48 'proxi':3,7,15,78,101 'psql':21 'run':33 'server':43 'singl':92 'single-browser-connect':91 'standard':18 'studio':24,26 'support':86 'tcp':14,42 'test':84 'tool':61,68 'unlik':55 'v0.1.0':8 'via':53 'websocket':13,54,100 'websocket-tcp':12 'wire':47 'without':75","created_at":"2026-06-05T17:00:17.675861+00:00","updated_at":"2026-06-05T17:00:17.675861+00:00","problems":[{"fix":"Run proxy with a different port: bunx pg-browser-proxy -w 8080","cause":"WebSocket server default port 443 requires elevated privileges","error":"Error: listen EACCES: permission denied 0.0.0.0:443"},{"fix":"Use named import: import { connectProxy } from 'pg-browser-proxy'","cause":"Importing connectProxy as a default import instead of named import","error":"Error: connectProxy is not a function"},{"fix":"Use PGliteWorker from '@electric-sql/pglite/worker' and create worker with correct URL","cause":"Database instance does not support raw wire protocol (e.g., wrong PGlite export)","error":"TypeError: db.execProtocolRaw is not a function"},{"fix":"Start proxy with bunx pg-browser-proxy and ensure tcpPort matches client connection string","cause":"Proxy TCP server is not running or wrong host/port","error":"Error: connect ECONNREFUSED 127.0.0.1:5432"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/f0rr0/pg-browser-proxy#readme","github":"https://github.com/f0rr0/pg-browser-proxy","docs":null,"changelog":null,"pypi":null,"npm":"pg-browser-proxy","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}