Guide
Introduction
What Nuxt PGlite is and the pieces it is made of.
Nuxt PGlite wires PGlite, Postgres compiled to WebAssembly, into Nuxt. It comes in independent pieces you combine as you like:
- Server instance:
usePGlite()in your Nitro routes, a PGlite created on first use and configured inserver/pglite.config.ts. - Development socket: that database served over the Postgres wire protocol while
nuxt devruns, sopg, postgres.js, Drizzle,drizzle-kitorpsqlreach it throughDATABASE_URL. - Client instance: an in-browser PGlite in a Web Worker shared between tabs, with live-query composables. Off by default.
- DevTools: a PGlite tab in Nuxt DevTools to inspect each instance, run SQL and trigger your own actions.
- Migrations:
nuxt-pglite/migrationsapplies a folder of SQL migration files to the local database frominit, the same files production is built from. - Testing:
nuxt-pglite/testingbuilds a database from your server config for the test suite, in memory and forkable per test, with a vitestglobalSetupand a recipe for@nuxt/test-utils.
Each piece is only in your bundle when it is enabled. @electric-sql/pglite is a peer dependency: you pick its version and import its extensions yourself, and the types follow your config.