Azure PostgreSQL modules for JavaScript

The recommended client library for accessing Azure Database for PostgreSQL is the open-source JavaScript connection library for Azure Database for PostgreSQL. This library is a non-blocking PostgreSQL client for JavaScript, supporting pure JavaScript and optional native libpq bindings.

Learn more about Azure Database for PostgreSQL

Client package

Install the npm module

Use npm to install the PostgreSQL client module.

npm install pg


This example opens a client connection and executes a simple query.

const pg = require('pg');

const connectionString =

const client = new pg.Client(connectionString);

const query = 'SELECT * FROM {table-name}';
client.query(query, (err, res) => {


JavaScript code snippets using PostgreSQL Learn how to create a pool, execute a query, obtain an exclusive client, and more.

For more code samples that use various Azure packages, explore the JavaScript samples.