pg-extension is a lightweight, TypeScript-first PostgreSQL client library built on top of the popular `pg` package. Version 0.3.8 (stable) provides a simple, promise-based API for querying Postgres with strong type inference, minimal configuration, and automatic connection pooling. It differentiates from `pg` directly by offering a more ergonomic interface with built-in parameterized queries, transaction support, and TypeScript generics for result types. Ideal for Node.js projects using TypeScript.
npm install pg-extensionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating a pool, running queries with tagged template literals and parameters, and using transactions.
Use `import { createPool } from 'pg-extension'` and call `createPool({...})` instead of `new Pool({...})`.Use manually constructed strings or aliases for dynamic identifiers. Never interpolate user input into identifiers.
Check for null: `const count = result.rowCount ?? 0;`
Replace `import { Pool } from 'pg-extension'` with `import { createPool } from 'pg-extension'`.Run `npm install pg-extension pg` (pg is a peer dependency). Ensure you are using ESM: `"type": "module"` in package.json or use `.mjs` extension.
Use named import: `import { createPool } from 'pg-extension'`.Add `"type": "module"` to package.json or rename file to `.mjs`. Alternatively, use dynamic import: `const { createPool } = await import('pg-extension')`.