node-postgres
A strong pick. 1st of 10 database drivers.
node-postgres (pg) is the standard PostgreSQL client for Node.js. It is mature and still gets new features, such as ESM support in 8.15 and query pipelining in 8.23. It is the safest default for a new Postgres project, and Postgres.js is the main alternative for teams that want a tagged-template API.
Best for: Any Node.js team that talks to PostgreSQL and wants the most widely supported driver that works with any ORM or query builder.
Scores
Overall8.7
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 8.5, likely 7.5 to 9.0
pg is the default Postgres driver for Node.js. It is deep, maintained, compatible with almost every ORM and growing faster than the median. Postgres.js offers a nicer API and the Neon driver suits serverless edge runtimes, but for most new Postgres projects pg remains the safest choice. Bundled TypeScript types and a smaller backlog would push it higher.
- npm downloadsLast4Weeks: Leads the category, ratio 8.3 against a 4.1 median
- github.com/brianc/node-postgres/blob/master/CHANGELOG.md: Steady feature releases through 8.23
- peers Postgres.js: Main Postgres alternative, with 151M downloads and far fewer dependents
GPT-6.2 Sol: 8.8, likely 7.6 to 9.6
For a new Node.js service using PostgreSQL, `pg` combines a mature query API, regular releases, and integration support from Prisma and Cloudflare. Postgres.js is a strong peer for teams that want built-in types, tagged SQL, and a transaction helper. Manual transaction handling and uneven repository security controls keep the recommendation below the top of the scale.
- github.com/brianc/node-postgres/blob/master/CHANGELOG.md: The stable v8 line continues to gain PostgreSQL features.
- prisma.io/docs/guides/upgrade-prisma-orm/v7: Prisma uses pg for its conventional PostgreSQL connection path.
- developers.cloudflare.com/hyperdrive/examples/connect-to-postgres: Cloudflare recommends pg for PostgreSQL on Hyperdrive.
- github.com/porsager/postgres: The closest peer offers bundled types and higher-level SQL and transaction APIs.
- scorecard score and checks: Preventive repository controls remain uneven.
Needed by many6.1
How many developers need a tool for this job?
Claude Opus 5.5: 6.0, likely 5.0 to 7.0
Most back-end and full-stack JS developers need a database driver, and PostgreSQL is the most popular relational database for new projects. Still, pg serves only Postgres and Node-like runtimes, so it is narrower than the whole category. Many of its users reach it through an ORM.
- dependents: 273k dependent repos, far more than any other SQL driver among the peers
- Stack Overflow Developer Survey: PostgreSQL has been the most used database in recent surveys
GPT-6.2 Sol: 6.2, likely 5.1 to 7.3
PostgreSQL serves a large share of backend developers, and production telemetry shows growing Node.js use with it. The driver also supports Bun, Deno, and Cloudflare Workers, although its scope is limited to PostgreSQL. The survey leaves the share of JavaScript and TypeScript teams that choose a low-level PostgreSQL driver uncertain.
- survey.stackoverflow.co/2026/technology/data: PostgreSQL led database admiration in the 2026 survey.
- datadoghq.com/state-of-postgres: Node.js was one of the most common ecosystems accessing PostgreSQL in production.
- node-postgres.com: Lists supported runtimes and PostgreSQL versions.
Helps a lot8.3
How well does it do the job for those who need it?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
It is feature-complete and well tested: pooling, a pure-JS client plus an optional libpq binding, SSL and SCRAM options, a per-query timeout, ESM support, and now pipelining with a measured 1.5-2.4x throughput gain. In an independent benchmark the pure-JS client was slightly faster than Postgres.js. It loses points because its types come from DefinitelyTyped and its API is less ergonomic than Postgres.js.
- github.com/brianc/node-postgres/blob/master/CHANGELOG.md: Steady features from 8.12 to 8.23: ESM, minimum pool size, onConnect, sslnegotiation=direct, pipelining
- dev.to/nigrosimone/benchmarking-postgresql-drivers-in-nodejs-node-postgres-vs-postgresjs-17kl: 2025 benchmark: pg 183µs vs postgres.js 202µs per query
- blog.platformatic.dev/query-pipelining-in-node-postgres-2-3x-throughput-with-one-line-of-code: Pipelining gives 1.5-2.4x throughput
- dev.to/pavkode/comparing-nodejs-postgres-client-libraries-briancnode-postgres-vs-porsagerpostgres-for-35jd: Says pg is better for complex transactions and bulk inserts, Postgres.js for simple queries
- npm hasTypes: No bundled types; @types/pg needed
GPT-6.2 Sol: 8.6, likely 7.5 to 9.5
Stable `pg` 8.23.1 covers pooled parameterized queries, streaming, and opt-in pipelining. The docs give coding agents clear examples, but a transaction still requires correct connection handling and TypeScript row types are supplied separately. Postgres.js offers a transaction helper and bundled types. An independent benchmark found `pg` competitive on an earlier 8.x build, so performance on current workloads remains uncertain.
- npm latestVersion and hasTypes: Stable version 8.23.1 ships without TypeScript declarations.
- node-postgres.com/features/pipelining: Pipelining is opt-in and requires a checked-out client when using a pool.
- node-postgres.com/features/transactions: Documents manual rollback, release, and same-client transaction handling.
- raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/pg/index.d.ts: Community declarations include generic row types and the pipeline option.
- github.com/porsager/postgres: Documents bundled types, tagged SQL templates, and a transaction helper.
- dev.to/nigrosimone/benchmarking-postgresql-drivers-in-nodejs-node-postgres-vs-postgresjs-17kl: Independent single-workload test found pg 8.16.3 competitive with Postgres.js.
Holds up over time8.1
Will it still be a good choice in two years?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
The project has been active for 16 years. It had 114 commits and 10 npm releases in the last year, still ships new features, and supports Node 26. The 8.x line has avoided breaking changes. The main risks are a large open backlog and a release process that depends on a small core team led by the original author.
- github commitsLastYear: 114 commits in the last year
- npm versionsLastYear: 10 versions; latest 8.23.1 on 2026-09-30
- github openIssues/openPullRequests: 468 open issues and 126 open PRs
- github.com/drizzle-team/drizzle-orm/issues/6118: The ecosystem is picking up the new pipelining feature
GPT-6.2 Sol: 8.2, likely 7.0 to 9.2
The repository logged 114 commits and npm received 10 versions in the past year. Sponsorship and steady additions within v8 support continued maintenance. The open issue and pull request backlog, unclear release ownership, and planned removal of the internal query queue in v9 leave some uncertainty about response times and upgrade effort.
- github commitsLastYear, openIssues, openPullRequests and releasesLastYear: 114 commits, 468 open issues, 126 open pull requests, and zero GitHub Release entries.
- npm versionsLastYear and latestPublishedAt: Ten npm versions in a year, with the latest published September 30, 2026.
- github.com/brianc/node-postgres/blob/master/CHANGELOG.md: Recent v8 releases added pipelining and direct TLS negotiation.
- node-postgres.com: Credits GitHub sponsors and a year of Medplum sponsorship.
- github.com/brianc/node-postgres/issues/3633: The maintainer put removal of the deprecated query queue on the v9 milestone.
Used widely8.5
How many use it, and is that growing?
Claude Opus 5.5: 9.0, likely 8.0 to 10.0
It has about 390M downloads in 4 weeks, up from 47M a year ago. That ratio of 8.3 is twice the 4.1 median, and pg leads the category in downloads. Many of those downloads come through ORMs and CI, but its 273k dependent repos show that a very large number of projects choose it directly.
- npm downloadsLast4Weeks: 390M, up from 47.3M a year ago
- dependents: 273,357 repos and 8,927 packages
- github stars: 13.2k stars
GPT-6.2 Sol: 8.0, likely 6.9 to 9.0
Ecosyste.ms found 273,357 dependent repositories, far more than for Postgres.js and fewer than for the MongoDB driver. Four-week downloads grew 8.3 times year over year, above the 4.1 times catalog median but behind Postgres.js at 29.1 times. Repeat CI installs and dependencies such as Prisma’s adapter inflate download counts, so the pace of direct adoption is harder to estimate.
- dependents repos and packages: The index found 273,357 dependent repositories and 8,927 dependent packages.
- npm downloadsLast4Weeks, downloadsSame4WeeksYearAgo and medianDownloadsRatio: 390.5 million installs versus 47.3 million a year earlier, against a 4.1 times median.
- peers Postgres.js and MongoDB driver: Postgres.js grew 29.1 times from a smaller base. MongoDB had 828,772 indexed dependent repositories.
- github stars and bluesky posts: 13,239 stars and four Bluesky posts link to the whole repository.
- prisma.io/docs/guides/upgrade-prisma-orm/v7: Prisma’s PostgreSQL adapter brings pg into projects indirectly.
Vouched for8.3
Who stands behind it being good?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
The major ORMs and query builders (Drizzle, Kysely, Knex, TypeORM, Sequelize, Prisma's pg adapter) build on it, and the Neon driver keeps its API. Independent benchmarks and write-ups recommend it for robust workloads. Survey data that names pg itself is thin.
- ORM ecosystem: Drizzle, Kysely, Knex, TypeORM and Prisma adapters use pg as their Postgres driver
- blog.platformatic.dev/query-pipelining-in-node-postgres-2-3x-throughput-with-one-line-of-code: A third-party company writes about it and benchmarks it
- dev.to/nigrosimone/benchmarking-postgresql-drivers-in-nodejs-node-postgres-vs-postgresjs-17kl: Independent benchmark
GPT-6.2 Sol: 8.6, likely 7.5 to 9.5
Prisma ORM 7 uses `pg` for its standard PostgreSQL adapter, Cloudflare recommends it for Hyperdrive, and Medplum ships it in its server. Independent testing found competitive performance on one workload. Driver-specific satisfaction data is scarce, and users have reported a shutdown regression on Cloudflare Workers.
- prisma.io/docs/guides/upgrade-prisma-orm/v7: Prisma ORM 7 builds its standard PostgreSQL adapter on pg.
- developers.cloudflare.com/hyperdrive/examples/connect-to-postgres: Cloudflare recommends pg for compatibility with Hyperdrive caching.
- raw.githubusercontent.com/medplum/medplum/main/packages/server/package.json: Medplum Server pins pg 8.23.1 as a runtime dependency.
- dev.to/nigrosimone/benchmarking-postgresql-drivers-in-nodejs-node-postgres-vs-postgresjs-17kl: An independent benchmark measured competitive latency on an earlier v8 build.
- github.com/brianc/node-postgres/issues/3805: A user confirmed the Workers shutdown error in production.
Safe7.6
How safe is it to depend on?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
There is only one advisory, a 2018 remote-code-execution bug that was fixed quickly, and none in the last 24 months. It pulls in about six small dependencies, mostly its own pg-* packages, and uses the MIT licence. Its OpenSSF Scorecard of 5.7 shows gaps: no security policy, no branch protection, unpinned dependencies and no SAST.
- advisories: 1 advisory in total (2018), 0 in the last 24 months
- scorecard: 5.7; Security-Policy, Branch-Protection, Pinned-Dependencies and SAST all score 0
- npm dependencies: 6 dependencies
- npm license: MIT
GPT-6.2 Sol: 7.1, likely 5.9 to 8.1
The package uses the permissive MIT license and has five required dependencies plus one optional dependency. The maintainer shipped fixes for the old critical advisory on the day it was reported, and the collector found zero new advisories for `pg` in the last two years. OpenSSF scored the repository 5.7, with gaps in branch protection, dependency pinning, fuzzing, and security policy. Release provenance and the number of authorized publishers remain unverified.
- advisories total and last24Months: One historical advisory and zero in the last two years.
- node-postgres.com/announcements#2017-08-12: The maintainer announced same-day fixes across affected version lines.
- github.com/brianc/node-postgres/blob/master/packages/pg/package.json: MIT license, five regular dependencies, and one optional Cloudflare dependency.
- scorecard score and checks: 5.7 overall. Packaging and signed releases were unscored, and several preventive controls scored zero.
Good
- Drizzle, Kysely, Knex, TypeORM, Prisma's pg adapter and many other tools build on it, so it fits almost any stack.
- It has a complete feature set: pooling, parameterized and prepared queries, cursors, LISTEN/NOTIFY, SCRAM with channel binding, an optional libpq binding and, since 8.23, opt-in pipelining.
- The 8.x line has stayed compatible for years, so upgrades rarely break code.
- Docs and examples are everywhere, so AI coding agents usually write correct code for it.
Bad
- Types are not shipped in the package; you install @types/pg from DefinitelyTyped, and those types can drift from the code.
- The API is older and more verbose than Postgres.js, whose tagged templates make queries both safe and short.
- The backlog is large, with about 470 open issues and 126 open pull requests, and some pool edge cases (stale connections after failover) come up again and again.
- Its OpenSSF Scorecard is a middling 5.7, with no security policy, no branch protection and unpinned dependencies.
The numbers
- npm downloads, 4 weeks
- 390M ×8.3 in a year
- GitHub stars
- 13k
- Commits, 12 months
- 114
- npm version
- 8.23.1 Sept 2026
- Versions, 12 months
- 10
- Advisories, 24 months
- 0 of 1 ever
- OpenSSF Scorecard
- 5.7 out of 10, Nov 2026
- Licence
- MIT
Read on 21 November 2026 from GitHub (brianc/node-postgres), npm (pg), OSV and the OpenSSF Scorecard.
Database drivers
- 8.7node-postgres
- 8.2MongoDB driver
- 8.1better-sqlite3
- 8.0MySQL2
- 7.6PGlite
- 7.5Postgres.js
- 7.4DuckDB Node Neo
- 7.1Neon serverless driver
- 5.9libSQL client
- 1.9node-sqlite3