PGLite: Run Full PostgreSQL in Browser and Node.js via WebAssembly
PGLite enables running a full PostgreSQL database directly in the browser or Node.js via WebAssembly, no external services needed.
PGLite: Full PostgreSQL in Your Browser via WebAssembly
PGLite compiles complete PostgreSQL to WebAssembly, running directly in browsers or Node.js without installation or external connections. This is full Postgres — JOINs, CTEs, window functions, JSONB, transactions with ACID compliance.
Why Not SQLite WASM?
PGLite offers richer JSON operations, window functions, type system (arrays, ENUMs, composite types), and extension ecosystem potential (PostGIS, pgvector WASM ports).
Use Cases
Local-first applications with on-device data storage, offline PWAs with full database operations, rapid prototyping without backend setup, and frontend unit testing with real Postgres engines.
WebAssembly Infrastructure Trend
PGLite marks WASM's practical advancement in critical infrastructure — from SQLite to PostgreSQL, proving WASM as a genuine universal computing platform. Next: Redis, vector databases, and message queues running in the browser.
Performance Benchmarks
Chrome 126 benchmarks: simple SELECT on 100K rows ~200ms (400x slower than server Postgres but acceptable for frontend), three-table JOIN with GROUP BY on 10K rows ~500ms, single INSERT ~1ms, batch INSERT of 1000 rows ~200ms. Core WASM module is ~15MB with database instance consuming 50-100MB memory.
Ecosystem Positioning
sql.js (SQLite WASM): most mature and lightweight for simple storage. absurd-sql (SQLite+IndexedDB): adds persistence for offline use. PGLite: most powerful but heaviest, the only browser-native database supporting JSONB deep operations, window functions, and rich type systems.
Local-First Movement Catalyst
PGLite aligns with the Local-First software movement — data ownership stays with users. In Local-First architecture, PGLite serves as the primary frontend database with CRDT-based synchronization to server-side Postgres (Electric SQL, PGLite's parent project, is building this 'local Postgres + cloud Postgres real-time sync' architecture). This is especially valuable for privacy-sensitive applications where user data is processed and stored locally, with cloud sync only when explicitly requested.
Adoption Challenges
Despite promise: browser compatibility issues with some older mobile browsers and WebViews, lack of visual debugging tools (no pgAdmin equivalent for in-browser PGLite), and migration costs from existing SQLite WASM applications.
Real-World Adoption Case Studies
Several notable projects have adopted PGLite in production:
Excalidraw (collaborative whiteboard). Uses PGLite for local-first shape and canvas state management, enabling offline drawing with later sync. The full Postgres JSON operations proved essential for complex canvas state queries.
Tiptap (rich text editor). Evaluating PGLite for local document storage with full-text search, leveraging Postgres's built-in text search capabilities that SQLite lacks.
Linear-style project management tools. Several startups building Linear competitors use PGLite for offline-capable project management with complex relational queries (issues → projects → milestones → users) that would require workarounds in SQLite.
Future: PostgreSQL Extensions in WASM
The most exciting long-term potential is porting PostgreSQL extensions to WASM. Imagine running pgvector (vector similarity search) in the browser for local AI applications, or PostGIS for offline mapping. The Electric SQL team is actively working on extension compatibility, with pgvector WASM being the highest-priority target given the AI use case demand.