Registry / database / zoo.pg

zoo.pg

JSON →
library1.5.9jsnpmunverified

A TypeScript-native Postgres client library (v1.5.x, monthly releases) with minimal dependencies and a focus on performance and type safety. Unlike pg or node-postgres, zoo.pg ships pre-built TypeScript types, requires no external drivers, and supports ESM-only imports. Designed for modern Node.js (14+) and Deno environments, it provides prepared statements, connection pooling, and transaction support out of the box.

npm install zoo.pg
INSTALL
IMPORT
SIG · ZOO.PG
Z
zoo.pg
databasejavascriptv1.5.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import postgres from 'zoo.pg'
✗ const postgres = require('zoo.pg')
ESM-only since v1.0; no CommonJS support.
sql
✓ import { sql } from 'zoo.pg'
✗ const { sql } = require('zoo.pg')
Named export for tagged template literals.
PostgresError
✓ import { PostgresError } from 'zoo.pg'
✗ import PostgresError from 'zoo.pg'
Named export, not default.

Shows ESM import, connection setup with environment variable for password, simple query, and cleanup.

import postgres from 'zoo.pg'; const sql = postgres({ host: 'localhost', port: 5432, database: 'test', user: 'user', password: process.env.PGPASSWORD ?? '' }); async function main() { const result = await sql`SELECT 1 AS number`; console.log(result); // [{ number: 1 }] await sql.end(); } main().catch(console.error);
Debug
Known issues
breakingESM-only: require() not supported.
fix
Use import syntax instead of require().
affects: >=1.0.0
gotchaDefault export is not a function in some TypeScript setups; fails silently.
fix
Update to version 1.5.0 or later, or use explicit type annotation.
affects: >=1.0.0 <1.5.0
gotchaConnection pool default max is 10; not configurable via connection string.
fix
Pass options object with max: number when creating the client.
affects: >=1.0.0
breakingRenamed query parameter syntax from $1 to ? in v1.2.
fix
Replace $1 with ? in parameterized queries.
affects: >=1.2.0
Errors
Common errors & fixes
TypeError: postgres is not a function
Trying to use require() to import the module.
fix
Use import postgres from 'zoo.pg' instead of require.
Error: Must use import to load ES Module: /path/to/zoo.pg/index.mjs
Attempting to import with CommonJS require() or in a CJS project.
fix
Set "type": "module" in package.json or use .mjs extension.
SyntaxError: Unexpected token '?'
Old parameter placeholder $1 used instead of new ? syntax.
fix
Use ? as placeholder in parameterized queries.
Upgrade
Version history
1.5.9latest on npm
Audit
Dependencies
postgresrequiredRuntime dependency for actual PostgreSQL wire protocol implementation
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
packagezoo.pg ↗
zoo.pg — npm install zoo.pg · libregistry