Socket
Book a DemoInstallSign in
Socket

@prisma/adapter-pg

Package Overview
Dependencies
Maintainers
3
Versions
2878
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/adapter-pg

Prisma's driver adapter for "pg"

6.15.0
latest
Source
npmnpm
Version published
Weekly downloads
81K
-3.62%
Maintainers
3
Weekly downloads
 
Created
Source

@prisma/adapter-pg

This package contains the driver adapter for Prisma ORM that enables usage of the node-postgres (pg) database driver for PostgreSQL. You can learn more in the documentation.

pg is one of the most popular drivers in the JavaScript ecosystem for PostgreSQL databases. It can be used with any PostgreSQL database that's accessed via TCP.

Note:: Support for the pg driver is available from Prisma versions 5.4.2 and later.

Usage

This section explains how you can use it with Prisma ORM and the @prisma/adapter-pg driver adapter. Be sure that the DATABASE_URL environment variable is set to your PostgreSQL connection string (e.g. in a .env file).

1. Enable the driverAdapters Preview feature flag

Since driver adapters are currently in Preview, you need to enable its feature flag on the datasource block in your Prisma schema:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Once you have added the feature flag to your schema, re-generate Prisma Client:

npx prisma generate

2. Install the dependencies

Next, install the Prisma ORM's driver adapter for pg:

npm install @prisma/adapter-pg

3. Instantiate Prisma Client using the driver adapter

Finally, when you instantiate Prisma Client, you need to pass an instance of Prisma ORM's driver adapter to the PrismaClient constructor:

import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '@prisma/client'

const connectionString = `${process.env.DATABASE_URL}`

const adapter = new PrismaPg({ connectionString })
const prisma = new PrismaClient({ adapter })

Feedback

We encourage you to create an issue if you find something missing or run into a bug.

If you have any feedback, leave a comment in this GitHub discussion.

FAQs

Package last updated on 27 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.