Registry / database / prisma-adapter-postgres

prisma-adapter-postgres

JSON →
library1.0.2jsnpmunverified

Prisma driver adapter for the Porsager 'postgres' library, version 1.0.2. This adapter enables Prisma Client to use the porsager/postgres (sql) database driver instead of Prisma's default drivers. It is essential for environments like serverless, Edge, or when using the postgres library's features. Release cadence is low; it is a thin wrapper. Differentiators: specifically for the `postgres` npm package (not `pg`), TypeScript-first, minimal overhead.

npm install prisma-adapter-postgres
INSTALL
IMPORT
SIG · PRISMA-ADAPTER-POS
P
prisma-adapter-postgres
databasejavascriptv1.0.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.

PrismaPostgres
import { PrismaPostgres } from 'prisma-adapter-postgres'
import PrismaPostgres from 'prisma-adapter-postgres'
Default export is not available; use named import.
sql (postgres client)
import postgres from 'postgres'; const sql = postgres(process.env.DATABASE_URL);
const { PrismaPostgres } = require('prisma-adapter-postgres')
The adapter is ESM-only; CommonJS require will fail. Also postgres client default import.
PrismaClient
import { PrismaClient } from '@prisma/client'
Standard Prisma import.

Initializes postgres client, wraps it with PrismaPostgres adapter, and uses PrismaClient to create a user.

import postgres from 'postgres'; import { PrismaPostgres } from 'prisma-adapter-postgres'; import { PrismaClient } from '@prisma/client'; const sql = postgres(process.env.DATABASE_URL ?? ''); const adapter = new PrismaPostgres(sql); const prisma = new PrismaClient({ adapter }); async function main() { const user = await prisma.user.create({ data: { email: 'test@prisma.io', name: 'test' } }); console.log('Created user:', user.id); } main().catch(console.error).finally(() => prisma.$disconnect());
Debug
Known issues
gotchaEnsure you use postgres library v3 or later, as peer dependency requires ^3.0.0.
fix
Upgrade postgres to v3+.
affects: <3.0.0
gotchaThe adapter is only compatible with Prisma's driver adapters feature (Preview in Prisma 5.4+, GA in 5.10+).
fix
Upgrade Prisma to >=5.4.0 and enable driverAdapters preview feature.
affects: <5.4.0
gotchaDo not use this adapter with the `pg` package; it is specifically for `postgres` (sql) library.
fix
Use @prisma/adapter-pg if you need pg driver.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'prisma-adapter-postgres'
Missing installation or incorrect import path.
fix
Run `npm install prisma-adapter-postgres postgres` and ensure import path is correct.
TypeError: Class extends value undefined is not a constructor or null
Trying to import default export instead of named export.
fix
Use `import { PrismaPostgres } from 'prisma-adapter-postgres'` (curly braces).
PrismaClientInitializationError: Invalid `adapter` provided
adapter instance is not of type PrismaPostgres.
fix
Ensure adapter is created correctly: `const adapter = new PrismaPostgres(sql)`.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
postgresrequiredPeer dependency: the porsager/postgres library is required to create the SQL client instance.
@prisma/clientrequiredRequired for PrismaClient instantiation and type generation.
Agent activity
7 hits · last 30 days
node
4
Resources
prisma-adapter-postgres — npm install prisma-adapter-postgres · libregistry