Gathering detailed insights and metrics for @electric-sql/pglite
Gathering detailed insights and metrics for @electric-sql/pglite
Gathering detailed insights and metrics for @electric-sql/pglite
Gathering detailed insights and metrics for @electric-sql/pglite
@electric-sql/pglite-tools
Tools for working with PGlite databases
@electric-sql/pglite-react
Hooks for using PGlite
@electric-sql/pglite-socket
A socket implementation for PGlite enabling remote connections
@electric-sql/pglite-repl
A REPL, or terminal, for use in the browser with PGlite, allowing you to have an interactive session with your WASM Postgres in the page.
Embeddable Postgres with real-time, reactive bindings.
npm install @electric-sql/pglite
Typescript
Module System
Node Version
NPM Version
@electric-sql/pglite@0.3.5
Updated on Jul 15, 2025
@electric-sql/pglite-vue@0.2.23
Updated on Jul 15, 2025
@electric-sql/pglite-tools@0.2.10
Updated on Jul 15, 2025
@electric-sql/pglite-react@0.2.23
Updated on Jul 15, 2025
@electric-sql/pglite-sync@0.3.8
Updated on Jul 15, 2025
@electric-sql/pglite-repl@0.2.23
Updated on Jul 15, 2025
TypeScript (75.15%)
JavaScript (16.79%)
HTML (7.55%)
CSS (0.51%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
12,379 Stars
360 Commits
281 Forks
66 Watchers
34 Branches
53 Contributors
Updated on Jul 15, 2025
Latest Version
0.3.5
Package Id
@electric-sql/pglite@0.3.5
Unpacked Size
18.71 MB
Size
6.37 MB
File Count
241
NPM Version
10.8.2
Node Version
20.19.3
Published on
Jul 15, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
PGlite - the WASM build of Postgres from ElectricSQL.
Build reactive, realtime, local-first apps directly on Postgres.
PGlite is a WASM Postgres build packaged into a TypeScript client library that enables you to run Postgres in the browser, Node.js, Bun and Deno, with no need to install any other dependencies. It is only 3mb gzipped and has support for many Postgres extensions, including pgvector.
1import { PGlite } from '@electric-sql/pglite' 2 3const db = new PGlite() 4await db.query("select 'Hello world' as message;") 5// -> { rows: [ { message: "Hello world" } ] }
It can be used as an ephemeral in-memory database, or with persistence either to the file system (Node/Bun/Deno) or indexedDB (Browser).
Unlike previous "Postgres in the browser" projects, PGlite does not use a Linux virtual machine - it is simply Postgres in WASM.
For full documentation and user guides see pglite.dev.
It can be installed and imported using your usual package manager:
1import { PGlite } from '@electric-sql/pglite'
or using a CDN such as JSDeliver:
1import { PGlite } from 'https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/index.js'
Then for an in-memory Postgres:
1const db = new PGlite() 2await db.query("select 'Hello world' as message;") 3// -> { rows: [ { message: "Hello world" } ] }
or to persist the database to indexedDB:
1const db = new PGlite('idb://my-pgdata')
Install into your project:
NodeJS
1npm install @electric-sql/pglite
Bun
1bun install @electric-sql/pglite
Deno
1deno add npm:@electric-sql/pglite
To use the in-memory Postgres:
1import { PGlite } from '@electric-sql/pglite' 2 3const db = new PGlite() 4await db.query("select 'Hello world' as message;") 5// -> { rows: [ { message: "Hello world" } ] }
or to persist to the filesystem:
1const db = new PGlite('./path/to/pgdata')
PostgreSQL typically operates using a process forking model; whenever a client initiates a connection, a new process is forked to manage that connection. However, programs compiled with Emscripten - a C to WebAssembly (WASM) compiler - cannot fork new processes, and operates strictly in a single-process mode. As a result, PostgreSQL cannot be directly compiled to WASM for conventional operation.
Fortunately, PostgreSQL includes a "single user mode" primarily intended for command-line usage during bootstrapping and recovery procedures. Building upon this capability, PGlite introduces a input/output pathway that facilitates interaction with PostgreSQL when it is compiled to WASM within a JavaScript environment.
The build process of PGlite is split into two parts:
Docker is required to build the WASM module, along with Node (v20 or above) and pnpm for package management and building the TypeScript packages.
To start checkout the repository and install dependencies:
1git clone https://github.com/electric-sql/pglite 2cd pglite 3pnpm install
To build everything, we have the convenient pnpm build:all
command in the root of the repository. This command will:
/packages/pglite/release
.To only build the Postgres WASM module (i.e. point 1 above), run
1pnpm wasm:build
If you don't want to build the WASM module and assorted WASM binaries from scratch, you can download them from a comment under the most recently merged PR, labeled as interim build files, and place them under packages/pglite/release
.
To build all TypeScript packages (i.e. point 2 of the above), run:
1pnpm ts:build
This will build all packages in the correct order based on their dependency relationships. You can now develop any individual package using the build
and test
scripts, as well as the stylecheck
and typecheck
scripts to ensure style and type validity.
Or alternatively to build a single package, move into the package directory and run:
1cd packages/pglite 2pnpm build
When ready to open a PR, run the following command at the root of the repository:
1pnpm changeset
And follow the instructions to create an appropriate changeset. Please ensure any contributions that touch code are accompanied by a changeset.
PGlite builds on the work of Stas Kelvich of Neon in this Postgres fork.
PGlite is dual-licensed under the terms of the Apache License 2.0 and the PostgreSQL License, you can choose which you prefer.
Changes to the Postgres source are licensed under the PostgreSQL License.
No vulnerabilities found.
No security vulnerabilities found.