Wraps Payload's Postgres adapters so they run against an embedded PGlite database behind a loopback socket during development, tests and CI. A CLI starts PGlite and passes its URL to your dev server, while the wrapper returns your adapter unchanged when no PGlite URL is set. Works with the Postgres and Vercel Postgres adapters on Payload 3 and 4, and is not meant for production.
Real PostgreSQL for Payload CMS development, tests and CI with nothing to install: an embedded PGlite behind a loopback socket, and a wrapper that fits Payload's own Postgres adapters to it (v3 and v4)
Installation
npm i payload-pglite0
Stars
0
Forks
0
Open Issues
Today
Last Updated
0
Weekly Downloads
v
npm Version
Dependencies
Trends appear after 7 days of data. Collecting since Dec 6 — 1 daily snapshot so far.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1484879902-root)<a href="https://payloaddirectory.dev/plugins/1484879902-root"><img src="https://payloaddirectory.dev/badge/1484879902-root.svg" alt="Payload Directory"></a>README
Real PostgreSQL for Payload CMS development, tests and CI, with nothing to install.
Run your app on an embedded Postgres (PGlite) through the same Postgres adapter you deploy with,
and leave production untouched.
npx payload-pglite next dev
# PGlite starts in .cache/pglite, Next.js gets PAYLOAD_PGLITE_URL, and Payload runs on Postgres
// payload.config.ts: your deployed config, plus one wrapper
db: withPGlite(postgresAdapter({ pool: { connectionString: process.env.DATABASE_URL } }), {
url: process.env.PAYLOAD_PGLITE_URL, // set in development only
}),
Payload on Postgres usually means running a database server for development: Docker, a local install, or a shared cloud branch. SQLite avoids that, but it is a different database, with a different adapter, different SQL and different behavior around transactions and locks. payload-pglite gives every checkout its own real Postgres, with no server:
@payloadcms/db-postgres or @payloadcms/db-vercel-postgres runs the same SQL, migrations and Drizzle schema it runs in production. You are not swapping in a different adapter for development.payload-pglite command starts it, hands your dev server its URL, and shuts it down cleanly..cache/pglite, on a port the OS picks, behind a lock: git worktrees and parallel projects never collide.startPGlite() gives each test file an in-memory database in under a second.req deadlocks against its own transaction. A production pool hides this until load; PGlite has one connection, so it fails at once, with an error that says how to fix it.npm install payload-pglite
npm install --save-dev @electric-sql/pglite @electric-sql/pglite-socket
The two PGlite packages are only needed by the payload-pglite command and by tests, so they stay in devDependencies.
import { postgresAdapter } from '@payloadcms/db-postgres'
import { buildConfig } from 'payload'
import { withPGlite } from 'payload-pglite'
export default buildConfig({
db: withPGlite(postgresAdapter({ pool: { connectionString: process.env.DATABASE_URL } }), {
url: process.env.PAYLOAD_PGLITE_URL,
}),
// ...
})
Prefer plugins? plugins: [pglitePlugin({ url: process.env.PAYLOAD_PGLITE_URL })] does the same. It works with vercelPostgresAdapter() too.
payload-pglite{
"scripts": {
"dev": "payload-pglite next dev",
"payload": "payload-pglite payload"
}
}
npm run dev now runs Payload on Postgres. npm run payload migrate:create and every other Payload CLI command use the same database. Deployments don't use the command, never get PAYLOAD_PGLITE_URL, and run your adapter as shipped.
The payload-pglite command starts PGlite behind a loopback Postgres socket (127.0.0.1, a port the OS picks), then runs your command with PAYLOAD_PGLITE_URL and DATABASE_URL set to it. When it sees that URL, withPGlite points your adapter at it and fits it to PGlite:
PGliteConnectionWaitError, which names the usual cause.payload-pglite commandpayload-pglite [--cwd <directory>] <command> [arguments...]
It runs any command: next dev, payload migrate, a seed script, turbo dev. It keeps the data in PAYLOAD_PGLITE_DATA_DIR (default .cache/pglite), forwards signals, exits with your command's exit code, and refuses NODE_ENV=production.
import { startPGlite } from 'payload-pglite/server'
const database = await startPGlite() // in memory; pass { dataDir } to keep it
const payload = await getPayload({
config: await buildConfig({
...config,
db: withPGlite(postgresAdapter({ pool: {} }), { url: database.url }),
}),
})
// ...
await payload.destroy()
await database.close()
→ Testing
push: true (the default in development) keeps the schema in step as you edit. When you write migrations, generate and run them against PGlite, the same engine and SQL as production:
npx payload-pglite payload migrate:create add-summary
npx payload-pglite payload migrate
withPGlite. Orders take stock in the same transaction, a refused order changes nothing, and concurrent orders never oversell.vercelPostgresAdapter with pglitePlugin. Editors sign in, drafts stay private, and published pages are public.req fails fast.payload-pglite, with push: false.Each example has its own README and tests that run in CI.
| Payload | 3 (≥ 3.94) and 4 (beta) |
| Adapters | @payloadcms/db-postgres, @payloadcms/db-vercel-postgres (without forceUseVercelPostgres) |
| PGlite | @electric-sql/pglite 0.5, @electric-sql/pglite-socket 0.2 |
| Node | 22, 24, 26+ (as Payload requires) |
| Use | Development, tests and CI. Never production. |
CI runs every suite on Payload 3 and 4. payload-pglite is pre-1.0, so minor versions may still change the API; the changelog lists every change.
Issues and pull requests are welcome. See CONTRIBUTING.md for setup, and TESTING.md for the suites.
payload integration test utils
Vitest helpers that give integration tests a ready Payload Local API instance backed by a containerized database
448/wk0v3
payload plugin template
Starter template for building Payload v3 plugins with a dev app, tests and Docker support
197v3
payload plugin tooling
Shared lint, format, TypeScript, build, test and CI config for developing Payload plugins
6039/wk0v4
payload dev tools
Floating dev toolbar, /dev pages and an app snapshot for AI agents in Payload projects on Next.js
5548/wk18v3
payload dry run
Test create operations with full validation and hooks, then roll back so nothing is persisted
439/wk0v3
payload typeid
TypeID identifiers for Payload collections, as native IDs or an extra type_id field, with PostgreSQL integrity guards
802.6k/wk0v3