pg
npmv8.23.0PostgreSQL client - pure javascript & libpq with the same API
Safe to adopt
Yes — pg scores well across adoption, maintenance, weight, supply chain, and licensing. 46.3M downloads per week and 5 known dependents. Last published 32 days ago. 26 releases in the last 2 years.
- AAdoption: grade A, Excellent.
46.3M downloads per week and 5 known dependents.
- AMaintenance: grade A, Excellent.
Last published 32 days ago. 26 releases in the last 2 years.
- BWeight: grade B, Good.
Pulls in 6 transitive packages, about 372 KB installed (at least — some of the tree is still being crawled).
- BSupply chain: grade B, Good.
This package has a single maintainer (bus factor of 1).
- ALicense: grade A, Excellent.
MIT — permissive, with no copyleft found in the dependency tree.
Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.
Install cost
What you actually take on by adding pg to a project.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
Longest resolved dependency chain below this package.
Part of this dependency tree has not been crawled yet, so these figures are a lower bound rather than a final total.
Licenses in the dependency tree
Every license you inherit by installing pg, not just its own. Check this before a legal review, not after.
Compatibility
- Node.js
- node >= 16.0.0
- Module format
- ESM + CommonJS
- TypeScript
- No bundled types
- Install scripts
- None
pg vs the alternatives
Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.
| Package | Weekly downloads | Dependents | License | Last release |
|---|---|---|---|---|
| pgthis page | 46.3M | 5 | MIT | 1 month ago |
| postgres | 0 | 1 | Unlicense | 1 day ago |
| drizzle-orm | 19M | 0 | Apache-2.0 | 1 day ago |
| pg-pool | 43.5M | 1 | MIT | 1 day ago |
| pgpass | 33M | 1 | MIT | 1 day ago |
| knex | 0 | 1 | MIT | 1 day ago |
Dependencies
Declared by pg v8.23.0. Runtime dependencies are installed with the package; dev dependencies are not.
Runtime (6)
Peer (1)
Dev (9)
Used by
Popular packages that depend on pg.
Connection pool for node-postgres
Module for reading .pgpass
Drizzle ORM package for SQL databases
Type safe SQL query builder
A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3
Relationship graph
Dependencies (left) and dependents (right) of pg.
Frequently installed together
fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS
The fastest and simplest library for SQLite in Node.js.
TypeScript definitions for pg
TypeScript definitions for better-sqlite3
TypeScript definitions for node
PGlite is a WASM Postgres build packaged into a TypeScript client library that enables you to run Postgres in the browser, Node.js and Bun, with no need to install any other dependencies. It is only 3.7mb gzipped.
Prettier is an opinionated code formatter
TypeScript Execute (tsx): Node.js enhanced with esbuild to run TypeScript & ESM files
Asynchronous, non-blocking SQLite3 bindings
The semantic version parser used by npm.
BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
Simple and robust resource pool for node.js
Release history
24 releases in the last two years, typically about 7 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 8.23.0latest | 1 month ago | 98 KB | MIT |
| 8.22.0 | 2 months ago | 93 KB | MIT |
| 8.21.0 | 3 months ago | 91 KB | MIT |
| 8.20.0 | 6 months ago | 90 KB | MIT |
| 8.19.0 | 6 months ago | 90 KB | MIT |
| 8.18.0 | 7 months ago | 89 KB | MIT |
| 8.17.2 | 7 months ago | 88 KB | MIT |
| 8.17.1 | 7 months ago | 88 KB | MIT |
| 8.17.0 | 7 months ago | 88 KB | MIT |
| 8.16.3 | 1 year ago | 86 KB | MIT |
| 8.16.2 | 1 year ago | 86 KB | MIT |
| 8.16.1 | 1 year ago | 86 KB | MIT |
| 8.16.0 | 1 year ago | 86 KB | MIT |
| 8.15.6 | 1 year ago | 86 KB | MIT |
| 8.15.5 | 1 year ago | 86 KB | MIT |
Overview
pg is an npm package that postgreSQL client - pure javascript & libpq with the same API. It is extremely widely used, with about 46.3M downloads per week and 5 known dependents in the graph. The latest version is 8.23.0, released under the MIT license.
Who should use it
Teams working in the npm ecosystem who need postgreSQL client - pure javascript & libpq with the same API and value a battle-tested, widely-adopted solution.
When not to use it
Consider an alternative if you need to minimize your dependency tree, have first-class TypeScript types out of the box, or if a more actively-maintained option better fits your npm stack.
Pros
- Large, well-established user base (46.3M weekly downloads).
- Clear open-source license (MIT).
Cons
- Large dependency tree (17 direct dependencies) increases install size and audit surface.
- No bundled TypeScript types (may require a separate @types package).
Auto-generated from collected registry metadata. No external claims are inferred.
Maintainers
Frequently asked questions
Should I use pg?
Yes — pg scores well across adoption, maintenance, weight, supply chain, and licensing. 46.3M downloads per week and 5 known dependents. Last published 32 days ago. 26 releases in the last 2 years.
How do I install pg?
Run `npm install pg` to add pg to your npm project.
How many dependencies does pg have?
pg declares 17 direct dependencies and pulls in 6 packages in total once its runtime tree is resolved totalling about 372 KB on disk.
What license is pg released under?
pg is distributed under the MIT license.
How popular is pg?
pg has approximately 46,345,814 downloads per week and 5 known dependent packages.
Is pg still maintained?
The most recent release of pg (v8.23.0) was published 1 month ago.
Does pg run install scripts?
No. pg does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.