{"schemaVersion":"1.0","record":{"label":"PGlite","description":"Embedded WebAssembly PostgreSQL with JavaScript APIs and optional browser or filesystem persistence.","aliases":["@electric-sql/pglite"],"kind":"software","website":"https://pglite.dev/","overview":"PGlite packages PostgreSQL compiled to WebAssembly behind a JavaScript and TypeScript client. It can run in a browser or JavaScript runtime without a separately installed PostgreSQL server. Its embedded model suits local application data and development tasks, but it has different connection and persistence constraints from a conventional database server.","license":"Apache-2.0 and PostgreSQL License, described by the project as dual licensing","lifecycle":"active","example":false,"features":[{"name":"Embedded PostgreSQL","status":"supported","detail":"WASM PostgreSQL executes through JavaScript APIs without a separate server installation.","useCase":"Embedding a local SQL database in JavaScript applications and development workflows","platforms":["Web","JavaScript","TypeScript","Node.js","Bun","Deno"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://pglite.dev/docs/about","locator":"Embedded PostgreSQL WASM and licensing statement","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"}]},{"name":"Browser persistence","status":"limited","detail":"IndexedDB loads files into memory; OPFS AHP needs a worker and is documented as unsupported in Safari.","useCase":"Embedding a local SQL database in JavaScript applications and development workflows","platforms":["Web","JavaScript","TypeScript","Node.js","Bun","Deno"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://pglite.dev/docs/filesystems","locator":"Memory, IndexedDB and OPFS AHP constraints","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"}]},{"name":"Multiple browser tabs","status":"limited","detail":"Worker wrapper proxies requests to one elected leader instance, not independent concurrent database connections.","useCase":"Embedding a local SQL database in JavaScript applications and development workflows","platforms":["Web","JavaScript","TypeScript","Node.js","Bun","Deno"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://pglite.dev/docs/multi-tab-worker","locator":"Single leader, re-election and extension exposure","retrievedAt":"2026-10-07T23:43:48Z","kind":"vendor"}]},{"name":"Unchanged database files across upgrades","status":"limited","detail":"Minor upgrades can break compatibility; documented path is dump and import.","useCase":"Embedding a local SQL database in JavaScript applications and development workflows","platforms":["Web","JavaScript","TypeScript","Node.js","Bun","Deno"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://pglite.dev/docs/upgrade","locator":"Minor version breaking changes and dump/import","retrievedAt":"2026-10-07T23:43:48Z","kind":"vendor"},{"url":"https://pglite.dev/docs/api","locator":"Query/exec, transaction, relaxed durability and datadir dumps","retrievedAt":"2026-10-07T23:44:12Z","kind":"vendor"}]}],"alternatives":[],"slug":"pglite","draftAlternatives":[{"targetSlug":"sql-js","status":"limited","detail":"Can replace embedded SQL storage when PostgreSQL semantics are wanted; SQLite files, dialect and persistence APIs require migration.","useCase":"Embedding a local SQL database in JavaScript applications and development workflows","platforms":["Web","JavaScript","TypeScript","Node.js","Bun","Deno"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://pglite.dev/docs/about","locator":"Embedded PostgreSQL WASM and licensing statement","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"},{"url":"https://github.com/sql-js/sql.js/blob/master/README.md","locator":"SQLite in memory and explicit export","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"}]}],"evidence":[{"url":"https://pglite.dev/docs/about","locator":"Embedded PostgreSQL WASM and licensing statement","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"},{"url":"https://pglite.dev/docs/","locator":"Runtime options, parameterized queries and exclusive connection","retrievedAt":"2026-10-07T23:43:30Z","kind":"vendor"},{"url":"https://pglite.dev/docs/filesystems","locator":"Memory, IndexedDB and OPFS AHP constraints","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"},{"url":"https://pglite.dev/docs/multi-tab-worker","locator":"Single leader, re-election and extension exposure","retrievedAt":"2026-10-07T23:43:48Z","kind":"vendor"},{"url":"https://pglite.dev/docs/upgrade","locator":"Minor version breaking changes and dump/import","retrievedAt":"2026-10-07T23:43:48Z","kind":"vendor"},{"url":"https://pglite.dev/docs/api","locator":"Query/exec, transaction, relaxed durability and datadir dumps","retrievedAt":"2026-10-07T23:44:12Z","kind":"vendor"},{"url":"https://github.com/electric-sql/pglite/blob/main/LICENSE","locator":"Apache 2.0 terms","retrievedAt":"2026-10-07T23:44:12Z","kind":"vendor"},{"url":"https://github.com/electric-sql/pglite/blob/main/POSTGRES-LICENSE","locator":"PostgreSQL license terms","retrievedAt":"2026-10-07T23:44:12Z","kind":"vendor"},{"url":"https://github.com/sql-js/sql.js/blob/master/README.md","locator":"SQLite in memory and explicit export","retrievedAt":"2026-10-07T23:43:41Z","kind":"vendor"}],"document":{"version":1,"references":[{"url":"https://pglite.dev/docs/about","locator":"Embedded PostgreSQL WASM and licensing statement","retrievedAt":"2026-10-07T23:43:41Z","id":"about","title":"What is PGlite","kind":"vendor"},{"url":"https://pglite.dev/docs/","locator":"Runtime options, parameterized queries and exclusive connection","retrievedAt":"2026-10-07T23:43:30Z","id":"start","title":"Getting started","kind":"vendor"},{"url":"https://pglite.dev/docs/filesystems","locator":"Memory, IndexedDB and OPFS AHP constraints","retrievedAt":"2026-10-07T23:43:41Z","id":"fs","title":"PGlite filesystems","kind":"vendor"},{"url":"https://pglite.dev/docs/multi-tab-worker","locator":"Single leader, re-election and extension exposure","retrievedAt":"2026-10-07T23:43:48Z","id":"worker","title":"Multi-tab worker","kind":"vendor"},{"url":"https://pglite.dev/docs/upgrade","locator":"Minor version breaking changes and dump/import","retrievedAt":"2026-10-07T23:43:48Z","id":"upgrade","title":"PGlite upgrade path","kind":"vendor"},{"url":"https://pglite.dev/docs/api","locator":"Query/exec, transaction, relaxed durability and datadir dumps","retrievedAt":"2026-10-07T23:44:12Z","id":"api","title":"PGlite API","kind":"vendor"},{"url":"https://github.com/electric-sql/pglite/blob/main/LICENSE","locator":"Apache 2.0 terms","retrievedAt":"2026-10-07T23:44:12Z","id":"apache","title":"PGlite Apache license","kind":"vendor"},{"url":"https://github.com/electric-sql/pglite/blob/main/POSTGRES-LICENSE","locator":"PostgreSQL license terms","retrievedAt":"2026-10-07T23:44:12Z","id":"postgres","title":"PostgreSQL license","kind":"vendor"},{"url":"https://github.com/sql-js/sql.js/blob/master/README.md","locator":"SQLite in memory and explicit export","retrievedAt":"2026-10-07T23:43:41Z","id":"sqljs","title":"sql.js overview","kind":"vendor"}],"overviewCitations":["about","start"],"licenseCitations":["about","apache","postgres"],"sections":[{"id":"database","heading":"Queries and transactions","paragraphs":[{"id":"database-detail","content":[{"text":"The client offers parameterized query calls and a separate exec method for multiple SQL statements without parameters. Its tagged SQL template also turns interpolated values into parameters. Interactive transactions commit when the callback promise resolves and roll back when it rejects. These APIs can support application data operations, but code must use the appropriate parameterized route for supplied values rather than building raw SQL by concatenation."}],"citations":["api"]}]},{"id":"storage","heading":"Choosing persistence deliberately","paragraphs":[{"id":"storage-detail","content":[{"text":"The default filesystem is in-memory and ephemeral. IndexedDB persistence in browsers loads database files into memory and flushes changed files after queries. Persisting to IndexedDB therefore does not mean the database stops occupying memory. OPFS AHP is a different backend that requires a worker; the inspected guide lists Chrome and Firefox support and a Safari access-handle limitation. Runtime support for PGlite does not imply identical availability of every storage backend."}],"citations":["fs"]}]},{"id":"durability","heading":"Query results and durable writes","paragraphs":[{"id":"durability-detail","content":[{"text":"With relaxedDurability enabled, the API returns results before the storage flush completes. This can improve responsiveness, but a returned result is not confirmation that the deferred flush finished. A datadir dump is designed for loading back into PGlite and is not promised compatible with other PostgreSQL versions. These distinctions should be reflected in backup and recovery design rather than inferred from a successful query."}],"citations":["api"]}]},{"id":"tabs","heading":"Sharing across tabs","paragraphs":[{"id":"tabs-detail","content":[{"text":"PGlite has a single exclusive database connection. The multi-tab worker facility starts workers for tabs, elects one leader and routes queries through its PGlite instance. When that leader closes, another election starts a replacement instance. This coordinates access rather than providing separate parallel connections. Extensions can run inside the worker, but their namespace is not automatically exposed on a main-thread worker proxy; plugin-specific integration may be needed."}],"citations":["worker"]}]},{"id":"upgrade","heading":"Upgrading stored databases","paragraphs":[{"id":"upgrade-detail","content":[{"text":"The upgrade guide warns that minor releases can introduce breaking changes. Its recommended path uses pg_dump with the previous PGlite version and imports the result into a new instance. Package upgrades for persistent applications should therefore include a data-migration plan instead of assuming existing storage can simply be reopened under the new version. No migration was executed during this research."}],"citations":["upgrade"]}]},{"id":"license","heading":"License and scope","paragraphs":[{"id":"license-detail","content":[{"text":"The project describes its distribution as dual-licensed under Apache 2.0 and the PostgreSQL License, and includes both texts. This is open-source software permission, not a managed hosting or synchronization entitlement. The embedded database can run locally; surrounding services and their operational requirements are separate."}],"citations":["about","apache","postgres"]}]},{"id":"comparison","heading":"Substitution considerations","paragraphs":[{"id":"comparison-detail","content":[{"text":"PGlite can substitute for "},{"text":"sql.js","targetSlug":"sql-js"},{"text":" when an application needs embedded SQL with PostgreSQL behavior and PGlite's storage options. sql.js instead embeds SQLite and supports SQLite file import/export. Shared SQL support does not make their files, schema features or APIs interchangeable. The assessment is limited to embedded-database workflows and does not claim conventional PostgreSQL-server concurrency or a tested migration."}],"citations":["about","start","sqljs"]}]}]},"id":"Q974","revision":1022,"updatedAt":"2026-10-13T17:31:06Z","sourceUrl":"https://substitutefor.net/entities/Q974?revision=1022"}}