Registry / database / pglite-prisma-adapter

pglite-prisma-adapter

JSON →
library0.7.2jsnpmunverified

Prisma driver adapter for PGlite, the embedded PostgreSQL database for JavaScript. Version 0.7.2 is the latest stable release. This package allows using Prisma ORM with PGlite, enabling in-process PostgreSQL databases without a database server. It supports transactions, migrations, and is compatible with Node.js 18+, Bun, Deno, and edge runtimes. Ships TypeScript types. Peer dependencies include @electric-sql/pglite >=0.2.0 and @prisma/client >=7.1.0. A key differentiator is the ability to run Prisma with an embedded Postgres, ideal for testing, development, and serverless environments.

npm install pglite-prisma-adapter
INSTALL
IMPORT
SIG · PGLITE-PRISMA-ADAP
P
pglite-prisma-adapter
databasejavascriptv0.7.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrismaPGlite
import { PrismaPGlite } from 'pglite-prisma-adapter'
const PrismaPGlite = require('pglite-prisma-adapter')
ESM-only package; no CommonJS support. Must use import syntax.
PrismaClient
import { PrismaClient } from '@prisma/client'
import { PrismaClient } from 'pglite-prisma-adapter'
PrismaClient is from @prisma/client, not from this adapter.
PGlite
import { PGlite } from '@electric-sql/pglite'
import { PGlite } from 'pglite-prisma-adapter'
PGlite is a separate package; the adapter only provides PrismaPGlite.

Shows full setup: init PGlite, create adapter, instantiate PrismaClient, run basic create/findMany queries.

import { PGlite } from '@electric-sql/pglite'; import { PrismaPGlite } from 'pglite-prisma-adapter'; import { PrismaClient } from '@prisma/client'; import 'dotenv/config'; const client = new PGlite(process.env.DATABASE_DIR ?? './pglite-db'); const adapter = new PrismaPGlite(client); const prisma = new PrismaClient({ adapter }); async function main() { const user = await prisma.user.create({ data: { email: 'test@example.com', name: 'Test User' }, }); console.log('Created:', user); const users = await prisma.user.findMany(); console.log('Users:', users); } main().catch(console.error).finally(() => prisma.$disconnect());
Debug
Known issues
breakingRequires @prisma/client >=7.1.0 (released early 2025). Older versions are incompatible.
fix
Update @prisma/client to version 7.1.0 or later.
affects: >=0.1.0
breakingESM-only package; cannot be used with require() or in CommonJS projects.
fix
Convert your project to ESM or use dynamic import().
affects: >=0.1.0
gotchaThe connection string in Prisma schema is required but ignored when using the adapter; must still be a valid PostgreSQL URL.
fix
Set datasource url to any valid PostgreSQL URL (e.g., postgresql://localhost:5432/mydb).
affects: >=0.1.0
gotchaPGlite database directory must exist or be writable; adapter does not create it automatically.
fix
Ensure DATABASE_DIR points to a directory that exists or use a path that can be created.
affects: >=0.1.0
deprecatedPreview feature 'driverAdapters' is required in Prisma schema; this may become stable in future versions.
fix
Add previewFeatures = ['driverAdapters'] to generator client in schema.prisma.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'PrismaPGlite' of ... as it is undefined.
Using CommonJS require() instead of ESM import.
fix
Change const { PrismaPGlite } = require(...) to import { PrismaPGlite } from 'pglite-prisma-adapter'
Error: Unknown argument: adapter. Did you mean to enable driverAdapters preview feature?
Missing 'driverAdapters' in prisma-generator previewFeatures.
fix
Update schema.prisma: generator client { provider = "prisma-client-js" previewFeatures = ["driverAdapters"] }
PrismaClientKnownRequestError: Invalid prisma.$transaction() usage: Must use interactive transactions or provide a string tag.
Using $transaction with an array but adapter requires interactive transactions.
fix
Use prisma.$transaction(async (tx) => { ... }) instead of array form.
Error: The database directory does not exist: ./some/path
PGlite cannot find the specified directory; mistyped path or directory not created.
fix
Create the directory or set DATABASE_DIR to an existing writable path.
Upgrade
Version history
0.7.2latest on npm
Audit
Dependencies
@electric-sql/pgliterequiredRequired as the underlying PGlite database driver; the adapter wraps PGlite instances.
@prisma/clientrequiredRequired Prisma runtime to use the adapter; must be version >=7.1.0.
Agent activity
2 hits · last 30 days
node
2
Resources
pglite-prisma-adapter — npm install pglite-prisma-adapter · libregistry