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

wa-multi-session

v4.2.3

Published

Multi Session Whatsapp Library

Readme

Whatsapp Multi Session - Connecting More Whatsapp Session in 1 App

Connecting Your app with Whatsapp Messaging

Lightweight library for whatsapp. Not require Selenium or any other browser.

Stand above Baileys Library.

Installation

Install package using npm

npm install wa-multi-session@latest

Then import your code

Using JS Module

import { Whatsapp, SQLiteAdapter } from "wa-multi-session";

or using CommonJS

const { Whatsapp, SQLiteAdapter } = require("wa-multi-session");

Initialization

Create new Whatsapp Instance

const whatsapp = new Whatsapp({
  adapter: new SQLiteAdapter(),

  // Optional: Add Listener/Callback
  onConnecting: (sessionId) => {
    console.log(`[${sessionId}] Connecting...`);
  },
  onConnected: (sessionId) => {
    console.log(`[${sessionId}] Connected`);
  },
  onDisconnected: (sessionId) => {
    console.log(`[${sessionId}] Disconnected`);
  },
});

Session Usage/Examples

Start New Session with QR Code

// create session with ID : session1

const session = await whatsapp.startSession("session1", {
  printQR: true, // print QR on terminal
});
// Then, scan QR on terminal

or Start Session with Pairing Code (Phone Number) (Experimental)

const session = await whatsapp.startSessionWithPairingCode("mysessionid", {
  phoneNumber: "6281234567890",
  onPairingCode(code) {
    console.log(`Pairing Code: ${code}`);
  },
});

Get All Session ID

const sessions = await whatsapp.getSessionsIds();
// returning all session ID that has been created

Get Session Data By ID

const session = await whatsapp.getSessionById("session1");
// returning session data

Messaging Usage/Examples

Send Text Message

await whatsapp.sendText({
  sessionId: "session1", // session ID
  to: "6281234567890",
  text: "Hi There, This is Message from Server!",
});

Send Image

const image = fs.readFileSync("./myimage.png"); // Buffer
const send = await whatsapp.sendImage({
  sessionId: "session1",
  to: "6281234567890",
  text: "My Image Caption",
  media: image, // can from URL too
});

Send Video

const video = fs.readFileSync("./myvideo.mp4"); // Buffer
const send = await whatsapp.sendVideo({
  sessionId: "session1",
  to: "6281234567890",
  text: "My Video Caption",
  media: video, // can from URL too
});

Send Document File

const filename = "mydocument.docx";
const document = fs.readFileSync(filename); // Buffer
const send = await whatsapp.sendDocument({
  sessionId: "session1",
  to: "6281234567890",
  filename: filename,
  media: document,
  text: "Hei, Check this Document",
});

Send Voice Note

const filename = "myaudio.mp3";
const audio = fs.readFileSync(filename); // Buffer
const send = await whatsapp.sendAudio({
  sessionId: "session1",
  to: "6281234567890",
  media: audio,
  asVoiceNote: true, // send as voice note (ptt)
});

Read a Message

await whatsapp.readMessage({
  sessionId: "session1",
  key: msg.key,
});

Send Typing Effect

await whatsapp.sendTypingIndicator({
  sessionId: "session1",
  to: "6281234567890",
  duration: 3000,
});

Send Poll

await whatsapp.sendPoll({
  sessionId: "session1",
  to: "6281234567890",
  poll: {
    name: "Your favorite programming language?",
    values: ["JavaScript", "Python", "Go", "Rust"],
    selectableCount: 1, // number of values can be selected
  },
});

Handling Incoming Message Examples

const whatsapp = new Whatsapp({
  adapter: new SQLiteAdapter(),
  onMessageReceived: async (msg) => {
    if (msg.key.fromMe || msg.key.remoteJid?.includes("status")) return;
    const sender = msg.key.participant || msg.key.remoteJid!;
    await whatsapp.readMessage({
      sessionId: msg.sessionId,
      key: msg.key,
    });
    await whatsapp.sendTypingIndicator({
      sessionId: msg.sessionId,
      to: sender,
      duration: 3000,
    });
    await whatsapp.sendText({
      sessionId: msg.sessionId,
      to: sender,
      text: `You said: ${msg.message?.conversation || ""}`,
      answering: msg, // for quoting message
    });
  },
});

Save Media Message (Image, Video, Document)

const whatsapp = new Whatsapp({
  adapter: new SQLiteAdapter(),
  onMessageReceived: async (msg) => {
    if (msg.message?.imageMessage) {
      // save image
      msg.saveImage("./myimage.jpg");
    }

    if (msg.message?.videoMessage) {
      // save video
      msg.saveVideo("./myvideo.mp4");
    }

    if (msg.message?.documentMessage) {
      // save document
      msg.saveDocument("./mydocument"); // without extension
    }
  },
});

Optional Configuration Usage/Examples

Set custom credentials directory

// use adapter to set custom directory
const adapter = new SQLiteAdapter({
  databasePath: "my_custom_dir/database.db",
});

Also Visit Headless Whatsapp Gateway API

Authors

Feedback or Support

If you have any feedback or support, please reach out to me at [email protected]