pglite-oxide
pglite-oxide embeds the Electric SQL PGlite
WASI PostgreSQL runtime in Rust. It gives Rust apps a local Postgres-compatible
database without shipping a native Postgres sidecar.
Use it when you want:
- local Postgres semantics in a Rust or Tauri app
- fast Postgres-backed tests without Docker or testcontainers
- a PostgreSQL connection URI for crates such as SQLx or
tokio-postgres - a small, embedded database boundary that stays on the Rust side of the app
The crate currently targets PostgreSQL 17.x PGlite builds, Rust 1.92+, and Wasmtime 44.
Install
The default path uses the bundled PGDATA template and compiled Wasmtime module cache. There are no startup flags to remember for ordinary apps.
Direct Embedded API
Use Pglite when your Rust code owns the database calls.
use Pglite;
use json;
For tests, use Pglite::temporary()?. Temporary databases clone a process-local
template cluster, so repeated tests avoid fresh initdb work.
PostgreSQL Client URI
Use PgliteServer when an existing library expects a PostgreSQL URL. Configure
client pools with one connection because the embedded runtime owns one backend.
For SQLx:
use PgliteServer;
use ;
async
For app persistence, use PgliteServer::builder().path("./.pglite").start()?.
Current Shape
pglite-oxide is a Wasmtime/WASI embedding of PGlite, not native libpglite
bindings. Fresh databases are created from the bundled PGDATA template, and
later process starts reuse the compiled module cache when possible.
Prefer the direct Pglite API when you do not need a PostgreSQL connection
string. Use PgliteServer for compatibility with existing Postgres client
crates.