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

b3s-baileys

v1.0.4

Published

Lightweight Baileys auth state adapter

Downloads

12

Readme

Lightweight Baileys auth state adapter using better-sqlite3 and NodeCache
Built for efficient, persistent, and cache-optimized WhatsApp authentication sessions.

Table of Contents

Installation

Install the package using your preferred JavaScript package manager:

npm

npm install b3s-baileys

pnpm

pnpm add b3s-baileys

yarn

yarn add b3s-baileys

bun

bun add b3s-baileys

System Dependencies (Linux/Termux)

If you're on Linux or Termux (Android), install required build tools before installation:

Linux (Debian/Ubuntu)

sudo apt update
sudo apt install -y build-essential python3

Termux (Android)

pkg install nodejs python make clang binutils

For build issues on Android/Termux:

export GYP_DEFINES="android_ndk_path=''"
npm install

Usage

import { makeWASocket, DisconnectReason, proto, initAuthCreds, BufferJSON } from '@whiskeysockets/baileys';
// or
// import { makeWASocket, DisconnectReason, proto, initAuthCreds, BufferJSON } from 'baileys';
import useBetterSqlite3AuthState from 'b3s-baileys';

const { state, saveCreds, resetSession } = await useBetterSqlite3AuthState(
  './session.db',  // SQLite database path
  { proto, initAuthCreds, BufferJSON }  // Baileys utils
);

// Initialize WhatsApp socket
const sock = makeWASocket({
  auth: state,
});

// Save credentials on update
sock.ev.on('creds.update', saveCreds);

// Example: Reset session
sock.ev.on('connection.update', async(update) => {
  const { lastDisconnect, connection } = update
  if (connection === "close") {
    const statusCode = lastDisconnect?.error?.output?.statusCode;
    if (statusCode === DisconnectReason.loggedOut) {
      await resetSession()
    }
  }
})

Description

b3s-baileys is a drop-in replacement for Baileys' default auth state management. It replaces file-based JSON storage with a single SQLite database for persistence and NodeCache for fast in-memory access (with 10-minute TTL and periodic checks).

Key Benefits:

  • Efficiency: Reduces I/O operations with caching.
  • Persistence: All auth data (creds, keys, signals) in one SQLite file.
  • Lightweight: Minimal overhead for bots and socket apps.

Ideal for WhatsApp bots, but scale to PostgreSQL/MySQL for high-traffic production.

Arguments:

  • dbPath (string): Path to SQLite file (auto-created if missing).
  • baileysUtils (object): { proto, initAuthCreds, BufferJSON } from Baileys. Validates inputs for errors.

Error Handling: Throws descriptive errors for invalid inputs, DB failures, or missing dependencies. Logs errors to console for reads/writes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Developed with ❤️ by Brother of Ijul.