A pure Go driver and toolkit for PostgreSQL, exposing PostgreSQL-specific features like LISTEN/NOTIFY and COPY.
brianc/node-postgres
Non-blocking PostgreSQL client for Node.js, with a pure JavaScript driver and optional native libpq bindings.
- Stars
- 13,230
- Forks
- 1,384
- Open issues
- 566
- Last commit
- 15 days ago
What is it?
node-postgres (npm package pg) is a PostgreSQL client for Node.js that also runs on bun, Deno and Cloudflare. It is written in pure JavaScript, with optional native libpq bindings that expose the same API as the pure JavaScript client.
The library covers the everyday needs of a Postgres application: connection pooling, parameterized queries, named prepared statements with query plan caching, and LISTEN/NOTIFY for async notifications. Bulk data can be moved with COPY TO and COPY FROM, and custom JavaScript-to-PostgreSQL data type conversion is supported.
The repository is a monorepo that also publishes related packages such as pg-pool, pg-cursor, pg-query-stream and pg-connection-string. It is intentionally light on abstractions, so it suits developers who want to write SQL directly rather than use an ORM.
Key features
- 01Pure JavaScript client with optional native libpq bindings sharing the same API
- 02Built-in connection pooling
- 03Parameterized queries and named statements with query plan caching
- 04Async notifications via LISTEN/NOTIFY
- 05Bulk import and export with COPY TO/COPY FROM
- 06Extensible JavaScript-to-PostgreSQL data type coercion
Use cases
- Backend services in Node.js that talk to a PostgreSQL database
- Serverless or edge functions on Cloudflare or Deno that need a Postgres driver
- Applications that rely on LISTEN/NOTIFY for real-time events
- Bulk data loading jobs using COPY
Quick start
- 1
Install the pg package from npm
npm install pg - 2
Read the documentation at node-postgres.com to connect and run queries
In collections
Topics
FAQ
- What is node-postgres?
- Non-blocking PostgreSQL client for Node.js, with a pure JavaScript driver and optional native libpq bindings. node-postgres (npm package pg) is a PostgreSQL client for Node.js that also runs on bun, Deno and Cloudflare. It is written in pure JavaScript, with optional native libpq bindings that expose the same API as the pure JavaScript client.
- Is node-postgres free to use? What license does it have?
- node-postgres is open source under the MIT license. Check the license terms before using it in commercial products.
- Is node-postgres still maintained?
- Actively maintained. The last commit to node-postgres was on Oct 23, 2026.
- What can I use node-postgres for?
- Backend services in Node.js that talk to a PostgreSQL database Serverless or edge functions on Cloudflare or Deno that need a Postgres driver Applications that rely on LISTEN/NOTIFY for real-time events Bulk data loading jobs using COPY
- How do I install node-postgres?
- Install the pg package from npm: npm install pg Read the documentation at node-postgres.com to connect and run queries
- Where can I get node-postgres?
- The source code and installation instructions are on GitHub: https://github.com/brianc/node-postgres
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
The official-style Type 4 JDBC driver that lets Java programs connect to and query PostgreSQL databases.
Async, pure Rust SQL toolkit with compile-time checked queries written as plain SQL, supporting PostgreSQL, MySQL/MariaDB, and SQLite.
A PostgreSQL extension for high-performance real-time analytics on time-series and event data.
A Rust framework for building PostgreSQL extensions, with tooling to set up, run, test and package them across Postgres versions.
A Postgres command-line client with auto-completion and syntax highlighting, an alternative to the stock psql shell.