PGlite

Embeddable Postgres in WASM — a real Postgres database that runs in the browser, Node.js, Bun, and Deno with no server to install.

Library
npm
v0.5.5
15,845stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity100
Maintenance100
Community64
Maturity48
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture88
Code Quality85
Innovation84
Learning Curve82

PGlite is a WebAssembly build of PostgreSQL packaged as a lightweight TypeScript client library, letting you run a real, single-connection Postgres instance directly inside the browser, Node.js, Bun, or Deno — with no server process, network socket, or native binary to install. At roughly 3MB gzipped, it ships as an npm package that persists to IndexedDB in the browser or the filesystem in server runtimes, and supports many of Postgres’ native extensions, including pgvector and PostGIS, making it well suited for local-first apps, embedded analytics, and fast test/CI databases.

Built by ElectricSQL, PGlite works by running Postgres’ built-in single-user mode — normally reserved for bootstrapping and recovery — inside an Emscripten-compiled WASM module, since regular multi-process Postgres can’t be compiled to WASM directly. The result is a genuine Postgres engine, not an emulation or subset, exposed through a small async query API, with companion packages for React/Vue bindings, live reactive queries, a Postgres wire-protocol socket server, and sync with ElectricSQL’s replication.

What You Get

  • A ~3MB gzipped WASM build of real PostgreSQL runnable via new PGlite() with zero native dependencies
  • Persistence adapters for IndexedDB (browser), the filesystem (Node/Bun/Deno), or in-memory ephemeral storage
  • A TypeScript client with query, exec, transaction, listen/unlisten, and tagged-template sql helpers
  • A live extension for reactive, auto-updating query subscriptions, plus a Worker adapter for running PGlite off the main thread
  • Optional Postgres extensions (pgvector, PostGIS, pg_trgm, hstore, ltree, and dozens more) loadable as separate packages
  • React and Vue binding packages, a browser REPL component, and a wire-protocol socket server for connecting regular Postgres clients like psql

Common Use Cases

  • Local-first web apps - Ship a real Postgres database inside the browser so apps keep working offline and sync changes later via ElectricSQL.
  • Fast, disposable test databases - Spin up an in-memory or file-backed Postgres instance per test run in CI without provisioning a database server.
  • Embedded analytics and reporting - Run SQL queries, aggregations, and pgvector similarity search directly inside a Node.js service or edge function.
  • Prototyping and demos - Give a browser-based playground or documentation site a fully queryable Postgres backend with no backend infrastructure.

Under The Hood

Architecture: PGlite centers on the PGlite class in src/pglite.ts (1,361 lines), which extends BasePGlite (src/base.ts) and drives an Emscripten-compiled Postgres binary through a manually-intercepted longjmp on Postgres’ main loop, letting a single WASM instance service one query at a time in Postgres’ “single user mode” (normally used only for bootstrap/recovery). Wire-protocol messages are built and parsed via the sibling @electric-sql/pg-protocol package rather than a socket, with #queryMutex/#transactionMutex/#listenMutex (from async-mutex) serializing access. A pluggable Filesystem abstraction (src/fs/) backs the data directory with IndexedDB (idbfs.ts), Node’s fs (nodefs.ts), OPFS (opfs-ahp.ts), or pure in-memory storage (memoryfs.ts), and src/extensionUtils.ts loads optional Postgres extensions (pgvector, PostGIS, etc.) as separate WASM/tarball bundles at init time. Companion packages in the same monorepo — pglite-sync, pglite-react, pglite-vue, pglite-repl, pglite-socket, and a live query layer (src/live/index.ts, 850 lines) — build on the core client via its public PGliteInterface.

Tech Stack: The core package is pure TypeScript compiled with tsup, published as dual ESM/CJS with per-entrypoint exports (., ./live, ./worker, ./nodefs, ./opfs-ahp, ./contrib/*). Runtime dependencies are minimal — the WASM Postgres binary itself, @electric-sql/pg-protocol and @electric-sql/pglite-utils (both workspace-internal), and async-mutex for concurrency control — keeping the client itself dependency-light while the WASM payload does the heavy lifting. The workspace uses pnpm workspaces, Changesets for versioned multi-package releases, and Docker to build the underlying Postgres WASM binary from a forked postgres-pglite submodule.

Code Quality: The packages/pglite test suite spans 30+ files under tests/ (basic, transactions via triggers/plpgsql, live, dump, array-types, exec-protocol, notify, templating, plus a tests/contrib/ subtree exercising individual Postgres extensions) run through Vitest across Node, Bun, Deno, and browser targets (test:runtimes, test:web). Error paths are explicit: src/errors.ts wraps raw Postgres DatabaseErrors with the originating query/params via makePGliteError, and throw new Error(...) appears deliberately across base.ts, pglite.ts, initdb.ts, and argsParser.ts rather than being swallowed. ESLint + Prettier are enforced via a stylecheck script, and @arethetypeswrong/cli checks published type exports don’t drift from runtime exports before publish.

API Design: The public surface centers on a handful of familiar, promise-based methods — query, exec, sql tagged templates, transaction, listen/unlisten — mirroring node-postgres idioms closely enough that existing Postgres-client mental models transfer directly. Getting started is a single line (const db = new PGlite()), with optional extensions, filesystem backend, and startup params all passed through one PGliteOptions object rather than scattered configuration calls. The README leads with runnable browser and Node/Bun/Deno snippets, and pglite.dev hosts a fuller docs site plus an in-browser REPL example, giving the library strong out-of-the-box discoverability for a fairly novel embedding model.

Used by 14 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
Rust
67%
MIT

Bun

Developer Tools

95,452

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
66
Dependency
Built with
Rust67%
C++19%
Updated today
TypeScript
93%
Apache 2.0

flue

AI Agents · Developer Tools

7,953

Build autonomous AI agents and powerful workflows with a programmable TypeScript harness that gives any model sessions, tools, sandboxes, and durable execution.

View details
67
Repo Health
82
Technical
75
Dependency
Built with
TypeScript93%
Updated 1 weeks ago
TypeScript
98%
AGPL 3.0

Kan

Project Management

5,357

An open-source, self-hostable Kanban board built as a modern Trello alternative with team workspaces, board permissions, and Trello import.

View details
85
Repo Health
78
Technical
67
Dependency
Built with
TypeScript98%
Updated 1 weeks ago
TypeScript
84%
Apache 2.0

ktx

Data Engineering · Analytics · AI Development

1,547

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
73
Repo Health
85
Technical
73
Dependency
Built with
TypeScript84%
Updated 1 months ago
TypeScript
79%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,593

Open-source AI agent monitoring that catches what will break next before your users do.

View details
86
Repo Health
88
Technical
67
Dependency
Built with
TypeScript79%
Python11%
Updated today
TypeScript
99%
Other

LobeHub

AI Assistants · Productivity · Automation

81,816

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
72
Dependency
Built with
TypeScript99%
Updated today
TypeScript
93%
Apache 2.0

Openship

Devops · Hosting Control Panel

11,078

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
82
Repo Health
85
Technical
65
Dependency
Built with
TypeScript93%
Updated today
Python
47%
Other

Arize Phoenix

Devops · Analytics · Monitoring

11,105

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Python47%
TypeScript41%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search