npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wwebjs-postgres

v1.0.0

Published

A PostgreSQL plugin for whatsapp-web.js library with enhanced features

Readme

Inspired by: This package was inspired by wwebjs-mongo, a MongoDB session store for whatsapp-web.js. We adapted the concept for PostgreSQL to offer an alternative database solution.


wwebjs-postgres

A PostgreSQL session store for whatsapp-web.js

Persist your WhatsApp Web sessions in PostgreSQL for reliable multi-device authentication.

Features

Reliable Session Storage - Never lose your WhatsApp session
Multi-Device Ready - Works with WhatsApp's multi-device feature
Automatic Backups - Regular session backups to prevent data loss
Easy Management - Simple API for session operations

Installation

npm install wwebjs-postgres pg whatsapp-web.js

Quick Start

const { Client, RemoteAuth } = require('whatsapp-web.js');
const { PostgresStore } = require('wwebjs-postgres');
const { Pool } = require('pg');

// Initialize PostgreSQL connection
const pool = new Pool({
  connectionString: process.env.DATABASE_URL || 'postgres://user:password@localhost:5432/whatsapp_sessions'
});

// Create session store
const store = new PostgresStore({ pool });

// Initialize WhatsApp client
const client = new Client({
  authStrategy: new RemoteAuth({
    store: store,
    backupSyncIntervalMs: 300000 // Backup every 5 minutes
  }),
  puppeteer: {
    headless: false // Show browser window (set true for production)
  }
});

client.initialize();

client.on('qr', (qr) => {
  console.log('Scan this QR to authenticate:');
  // Display QR code in terminal
  require('qrcode-terminal').generate(qr, { small: true });
});

client.on('ready', () => {
  console.log('Client is ready!');
});

Advanced Usage

Session Management

// Check if session exists
const exists = await store.sessionExists({ session: 'my-session' });

// Force delete a session
await store.delete({ session: 'old-session' });

// List all stored sessions
const sessions = await store.listSessions();

Custom Configuration

const store = new PostgresStore({
  pool: pool,
  tableName: 'custom_sessions_table', // Optional custom table name
  sessionIdPrefix: 'myapp-' // Optional session ID prefix
});

Database Setup

Your PostgreSQL database should have the following schema (automatically created if not exists):

CREATE TABLE whatsapp_sessions (
  session_id VARCHAR(255) PRIMARY KEY,
  session_data BYTEA NOT NULL,
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE INDEX idx_whatsapp_sessions_updated_at ON whatsapp_sessions(updated_at);

Troubleshooting

Connection Issues:

  • Verify your PostgreSQL server is running
  • Check connection string format: postgres://user:password@host:port/database

Session Problems:

  • Ensure the client has proper write permissions
  • Check storage space if sessions fail to save

Resources


Note: Always keep your session data secure. Never expose your database credentials or session files publicly.


Pro Tip: For production deployments, set headless: true and consider using a process manager like PM2 to keep your WhatsApp client running 24/7.