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.8
16,080 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
79 /100 Good
Development Activity 72
Maintenance 92
Community 64
Maturity 48
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 88
Code Quality 85
Innovation 84
Learning Curve 82

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 15 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

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
64
Dependency
Built with
TypeScript 100%
Updated 4 days ago
Rust
67%
MIT

Bun

Developer Tools

96,068

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
64
Dependency
Built with
Rust 67%
C++ 19%
TypeScript 10%
Updated 5 days ago
TypeScript
94%
Apache 2.0

flue

AI Agents · Developer Tools

8,383

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

View details
80
Repo Health
82
Technical
70
Dependency
Built with
TypeScript 94%
Updated 1 weeks ago
TypeScript
96%
AGPL 3.0

Kan

Project Management

5,703

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
TypeScript 96%
Updated 1 weeks ago
TypeScript
84%
Apache 2.0

ktx

AI Development · Analytics · Data Engineering

1,603

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
66
Repo Health
85
Technical
72
Dependency
Built with
TypeScript 84%
Updated 3 weeks ago
TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,686

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
TypeScript 78%
Rust 11%
Python 11%
Updated 1 weeks ago
TypeScript
99%
Other

LobeHub

AI Assistants · Automation · Productivity

82,864

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
66
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
94%
Apache 2.0

Openship

Devops · Hosting Control Panel

12,979

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
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 94%
Updated 5 days ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,641

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
67
Dependency
Built with
Python 49%
TypeScript 42%
Updated 4 days ago

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