npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@statewalker/db-pglite

v0.3.1

Published

PGlite (Postgres in WASM) driver for @statewalker/db-api, for Node.js and the browser.

Readme

@statewalker/db-pglite

What it is

A driver that implements Db from @statewalker/db-api on PGlite, Postgres compiled to WebAssembly, in Node.js or in the browser. Extensions such as pgvector are passed in by the caller.

Why it exists

Postgres-backed code (full-text search with tsvector, pgvector indexes) can then take a Db like every other engine here, instead of a PGlite instance, and be tested with the same conformance suite.

How to use

pnpm add @statewalker/db-pglite @electric-sql/pglite
pnpm add @electric-sql/pglite-pgvector   # only for the pgvector example below

@electric-sql/pglite (^0.5.15) is a peer dependency: install it yourself, so the driver and the extensions you pass share one PGlite. Pick the PGlite version your extensions are built for (@electric-sql/[email protected] needs PGlite 0.5.15, 0.0.17 needs 0.5.16).

| Import | Gives | Environment | | --- | --- | --- | | @statewalker/db-pglite | newPgliteDb; types PgliteDbOptions, Db, DbEntry | Node.js, browser |

newPgliteDb({ path?, extensions? }) returns Promise<Db>. Use $1, $2, ... placeholders. exec runs several statements; query runs one, with parameters.

Examples

import { vector } from "@electric-sql/pglite-pgvector";
import { newPgliteDb } from "@statewalker/db-pglite";

const db = await newPgliteDb({ path: "./pgdata", extensions: { vector } });
await db.exec("CREATE EXTENSION IF NOT EXISTS vector");
const rows = await db.query("SELECT $1::int + 1 AS n", [41]);

Internals

  • path is a PGlite data directory, not a file: a folder on Node.js, idb://<name> (IndexedDB) in a browser. Omit it for an in-memory database. This package's tests run on Node.js only.
  • The caller owns extensions. The driver loads what it is given and never runs CREATE EXTENSION; do that after opening.
  • No transactions helper. inTransaction from @statewalker/db-sqlite is SQLite-only and rejects this Db. Postgres runs BEGIN ... COMMIT as ordinary SQL inside one exec.
  • One call at a time. The Db is built by newSerialisedDb from @statewalker/db-sqlite (the lifecycle every driver shares): calls run in call order; close() waits for the calls made before it, then closes PGlite; a call made once close() has started rejects with db-pglite: the database is closed; a second close() is a no-op.
  • Values are PGlite's, with integers as the Db contract asks (number within ±(2^53 - 1), bigint beyond): BYTEA is a Uint8Array, DATE and TIMESTAMP(TZ) a Date, and NUMERIC/DECIMAL its exact decimal string ("1.25"), which PGlite returns to keep every digit; convert it with Number(value) where a double is enough. The conformance suite declares its BLOB column as BYTEA here (blobType).
  • Dependencies: @statewalker/db-api (types), @statewalker/db-sqlite (newSerialisedDb, the shared lifecycle wrapper; no SQLite engine comes with it); peer @electric-sql/pglite (the engine, provided by the caller).

License

MIT