pg
Non-blocking PostgreSQL client for Node.js — pure JavaScript with optional native bindings.
pg
Node.jsNon-blocking PostgreSQL client for Node.js — pure JavaScript with optional native bindings.
Fit
Bundle (gzip)
25.2 kB
83.3 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Talking to PostgreSQL from Node without an ORM means you still need reliable connection pooling, parameterized queries to prevent SQL injection, and proper handling of types and async results.
What It Does
pg (node-postgres) offers a clean client and connection pool, parameterized queries, cursors, and streaming. It is the de facto low-level PostgreSQL driver that most Node ORMs and query builders sit on top of.
Installation
npm install pgUsage Example
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const { rows } = await pool.query(
"SELECT id, email FROM users WHERE active = $1",
[true]
);
console.log(rows);Related packages
Role and attribute based access control (RBAC + ABAC) for Node.js with a fluent, readable API.
bcryptjsNode.jsPure JavaScript bcrypt password hashing — no native dependencies, same API as bcrypt, works anywhere Node.js runs.
bullmqNode.jsPremium message queue and job scheduler for Node.js backed by Redis — reliable background job processing with retries, priorities, and rate limiting.
casbinNode.jsA powerful authorization library that supports RBAC, ABAC, ACL and more via configurable policy models.
dotenvNode.jsLoad environment variables from a `.env` file into `process.env` — the standard way to manage configuration in Node.js apps.