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 🙏

© 2025 – Pkg Stats / Ryan Hefner

baileys-wa-master

v1.7.34

Published

Node.js master implementation for WhatsApp using Baileys

Readme

WA Master - WhatsApp Multi-Client Manager

WA Master is a scalable, efficient, and fault-tolerant multi-client management solution for WhatsApp built on Node.js using the Baileys library. This system leverages Redis for data storage and caching, providing robust features like event handling, worker threads, and LRU caching.

Features

  • Multi-client Management: Manage multiple WhatsApp clients simultaneously.
  • Worker Thread Architecture: Each client runs in its dedicated worker thread.
  • Redis Integration: Store and retrieve chats, messages, and other data efficiently using Redis.
  • Scalable and Resilient: Supports reconnections, error handling, and maximum restart attempts.
  • Event-driven System: Process and respond to various WhatsApp events like messages, presence updates, and connections.
  • TypeScript Support: Strong type safety for all components and handlers.

Table of Contents

Installation

Prerequisites

  • Node.js (>= 16.x)
  • Redis server (>= 6.x)

Steps

  1. Clone this repository:
git clone https://github.com/your-username/wa-master.git
cd wa-master
  1. Install dependencies:
npm install
  1. Start Redis server:
redis-server

Usage

Starting the Application

To start managing WhatsApp clients:

npm start

Sample Code

Below is an example to demonstrate adding and managing a WhatsApp client:

import { WAMaster } from './src/index';
import { WAClientConfig } from './src/client/types';

const master = new WAMaster();

const clientConfig: WAClientConfig = {
  clientId: 'unique-client-id',
  redisStoreUrl: 'redis://localhost:6379',
  browser: ['Chrome', '91', 'MacOS'],
};

master.startClient(clientConfig);

master.on('messages.upsert', (data) => {
  console.log('New messages:', data);
});

Configuration Options

RedisStorage

The RedisStorage class handles data operations using Redis. It provides methods to register, fetch, and clean up data.

Key Options:

| Option | Type | Default | Description | |------------------|---------------|------------|------------------------------------------------| | sessionId | string | Required | Unique identifier for the client session. | | redis | RedisClient | Required | Instance of Redis client for storage. | | logger | Logger | null | Optional logger for debugging. |

WAClientConfig

| Option | Type | Default | Description | |-------------------------|---------------|------------|--------------------------------------------| | clientId | string | Required | Unique client identifier. | | redisStoreUrl | string | Required | URL of the Redis instance. | | browser | string[] | Required | Browser information for WhatsApp Web. | | shouldSyncHistoryMessage | boolean | false | Whether to sync history messages. |

API Reference

WAMaster Class

startClient(clientConfig: WAClientConfig): void

Starts a new WhatsApp client with the given configuration.

stopClient(clientId: string): void

Stops a running WhatsApp client.

on<T>(event: T, callback: Function): void

Registers a callback for a specific event.

off<T>(event: T, callback: Function): void

Removes a callback for a specific event.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/your-feature.
  3. Commit your changes: git commit -m 'Add new feature'.
  4. Push the branch: git push origin feature/your-feature.
  5. Submit a pull request.

License

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


For more information, visit the GitHub Repository.