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

@alannxd/baileys

v6.2.7

Published

A WebSockets library for interacting with WhatsApp Web — fork of Baileys with extra socket layers (communities, interop, privacy, GraphQL) and special message helpers.

Readme

Baileys - Typescript/Javascript WhatsApp Web API

GitHub Downloads (all assets, all releases) NPM Downloads GitHub code size in bytes GitHub License Discord GitHub Repo stars GitHub forks

WhatsApp Baileys is an open-source library designed to help developers build automation solutions and integrations with WhatsApp efficiently and directly. Using websocket technology without the need for a browser, this library supports a wide range of features such as message management, chat handling, group administration, as well as interactive messages and action buttons for a more dynamic user experience.

Actively developed and maintained, baileys continuously receives updates to enhance stability and performance. One of the main focuses is to improve the pairing and authentication processes to be more stable and secure. Pairing features can be customized with your own codes, making the process more reliable and less prone to interruptions.

This library is highly suitable for building business bots, chat automation systems, customer service solutions, and various other communication automation applications that require high stability and comprehensive features. With a lightweight and modular design, baileys is easy to integrate into different systems and platforms.


Main Features and Advantages

  • Supports automatic and custom pairing processes
  • Fixes previous pairing issues that often caused failures or disconnections
  • Supports interactive messages, action buttons, and dynamic menus
  • Efficient automatic session management for reliable operation
  • Compatible with the latest multi-device features from WhatsApp
  • Lightweight, stable, and easy to integrate into various systems
  • Suitable for developing bots, automation, and complete communication solutions
  • Comprehensive documentation and example codes to facilitate development

Getting Started

Begin by installing the library via your preferred package manager, then follow the provided configuration guide. You can also utilize the ready-made example codes to understand how the features work. Use session storage and interactive messaging features to build complete, stable solutions tailored to your business or project needs.


Table of Contents

Requirements

  • Node.js >= 20
  • Optional peer deps depending on the features you use: sharp or jimp (image processing), link-preview-js (link previews), audio-decode (audio waveform)

Install

npm install @alannxd/baileys

Or alias it as baileys / @whiskeysockets/baileys in your package.json:

{
  "dependencies": {
    "@alannxd/baileys": "latest"
  }
}
import makeWASocket from '@alannxd/baileys'
// or, CommonJS:
const { default: makeWASocket } = require('@alannxd/baileys')

Quick Start

Login with QR Code

import makeWASocket, { Browsers, useMultiFileAuthState } from '@alannxd/baileys'

const { state, saveCreds } = await useMultiFileAuthState('auth_info')

const client = makeWASocket({
  browser: Browsers.ubuntu('Chrome'),
  printQRInTerminal: true,
  auth: state
})

client.ev.on('creds.update', saveCreds)

Login with Pairing Code

import makeWASocket, { Browsers, fetchLatestWAWebVersion, useMultiFileAuthState } from '@alannxd/baileys'

const { state, saveCreds } = await useMultiFileAuthState('auth_info')
const { version } = await fetchLatestWAWebVersion()

const client = makeWASocket({
  browser: Browsers.ubuntu('Chrome'),
  printQRInTerminal: false,
  version,
  auth: state
})

client.ev.on('creds.update', saveCreds)

if (!client.authState?.creds?.registered) {
  const phoneNumber = '628XXXXXXXXXX' // international format, no '+'
  const code = await client.requestPairingCode(phoneNumber)
  // custom pairing code (8 characters):
  // const code = await client.requestPairingCode(phoneNumber, 'YYYYYYYY')
  console.log('Pairing code:', code)
}

Store

makeInMemoryStore builds a local cache of chats/contacts/messages, which Baileys does not persist automatically by default.

import makeWASocket, { makeInMemoryStore } from '@alannxd/baileys'
import pino from 'pino'

const store = makeInMemoryStore({
  logger: pino().child({ level: 'silent', stream: 'store' })
})

const client = makeWASocket({ /* ...other options */ })
store.bind(client.ev)

client.ev.on('contacts.upsert', () => {
  console.log('New contact:', Object.values(store.contacts))
})

Need a persistent store (Redis, etc.)? Use makeCacheManagerStore — see API Reference.

Saving the store to a file

makeInMemoryStore can read/write its state to a local JSON file, so it survives restarts without needing an external database:

const store = makeInMemoryStore({ /* ... */ })

// load once on startup, then auto-save every 10s
const stopAutoSave = store.writeToFileInterval('./store.json')

process.on('SIGINT', () => {
  stopAutoSave()
  process.exit(0)
})

Or handle it manually with store.readFromFile(path) / store.writeToFile(path) — see API Reference for details.

Sending Messages

Generic send / relay

// relayMessage — send a raw message object, bypassing the sendMessage pipeline
await client.relayMessage(jid, { conversation: 'Hello from Baileys' }, {})

// sendMessage — the common way to send a message
await client.sendMessage(jid, { text: 'Hello from Baileys' })

Simple senders

All the sendX functions below are shortcuts on top of sendMessage.

await client.sendText(jid, 'Hi!', { contextInfo: { mentionedJid: [jid] } })
await client.sendImage(jid, { url: './photo.jpg' }, 'image caption')
await client.sendVideo(jid, { url: './clip.mp4' }, 'video caption')
await client.sendAudio(jid, { url: './clip.mp3' })
await client.sendLocation(jid, 'Location name', -6.2, 106.8, 'https://maps.example', '1234567890')
await client.sendPoll(jid, 'Pick one', ['Option 1', 'Option 2', 'Option 3'], /* multiSelect */ true)
await client.sendQuiz(jid, 'Correct answer?', ['1', '2', '3'], /* correctIndex */ '2')

Special message types

Handled internally by the Socket/luxu.js helper, invoked automatically via sendMessage/relayMessage whenever the content includes one of the fields below.

// Product message (catalog)
await client.relayMessage(jid, {
  productMessage: {
    title: 'Product Name',
    description: 'Product description',
    thumbnail: { url: './product.jpg' },
    productId: 'PRODUCT_ID',
    retailerId: 'RETAILER_ID',
    url: 'https://store.example/product',
    body: 'Body text',
    footer: 'Footer text',
    priceAmount1000: 72502, // price x 1000
    currencyCode: 'IDR'
  }
}, {})

// Order message
await client.sendMessage(jid, {
  thumbnail: fs.readFileSync('./thumb.jpg'),
  message: 'Order details',
  orderTitle: 'Store Name',
  totalAmount1000: 72502,
  totalCurrencyCode: 'IDR'
}, { quoted: m })

// Poll result snapshot (usually from a newsletter)
await client.sendMessage(jid, {
  pollResultMessage: {
    name: 'Poll Title',
    options: [{ optionName: 'Option 1' }, { optionName: 'Option 2' }],
    newsletter: { newsletterName: 'Newsletter Name', newsletterJid: '1234567890@newsletter' }
  }
})

// Interactive message (button)
await client.sendMessage(jid, {
  image: { url: './banner.jpg' },
  text: 'Message body',
  title: 'Title',
  footer: 'Footer',
  interactiveButtons: [{
    name: 'cta_url',
    buttonParamsJson: JSON.stringify({ display_text: 'Visit', url: 'https://example.com' })
  }]
})

// Group member label
await client.sendMessage(jid, {
  groupLabel: { labelText: 'Admin' }
})

// Broadcast to specific group members
await client.sendMessageMembers(jid, { extendedTextMessage: { text: 'Announcement' } }, {})

Fields like sender and participant: true in the second argument of sendMessage/relayMessage are used for group-participant send context — see docs/API.md for details on each socket layer.

Events

All interaction happens through events on client.ev:

client.ev.on('connection.update', ({ connection, lastDisconnect }) => {
  console.log('Connection status:', connection)
})

client.ev.on('messages.upsert', ({ messages, type }) => {
  for (const m of messages) {
    console.log('Incoming message:', m.message)
  }
})

client.ev.on('creds.update', saveCreds)

See the full list of events in lib/Types/Events.js.

Examples

Ready-to-run scripts live in examples/:

Known Limitations

  • No .d.ts for lib/ — only WAProto ships TypeScript types. Full autocomplete requires the TS source, which isn't included in this build.
  • Console banner on import — every time the package is imported, an ASCII art banner and promotional link are printed to stdout. In production or multi-instance setups this becomes log noise.
  • optionHash for per-option image polls is not implemented — it appears to require further reverse-engineering at the WhatsApp APK level.
  • See docs/API.md for other technical notes.

Why Choose WhatsApp Baileys?

Because this library offers high stability, full features, and an actively improved pairing process. It is ideal for developers aiming to create professional and secure WhatsApp automation solutions. Support for the latest WhatsApp features ensures compatibility with platform updates.


Technical Notes

  • Supports custom pairing codes that are stable and secure
  • Fixes previous issues related to pairing and authentication
  • Features interactive messages and action buttons for dynamic menu creation
  • Automatic and efficient session management for long-term stability
  • Compatible with the latest multi-device features from WhatsApp
  • Easy to integrate and customize based on your needs
  • Perfect for developing bots, customer service automation, and other communication applications
  • Has 1 newsletter follow, only the developer's WhatsApp channel: WhatsApp Channel

For complete documentation, installation guides, and implementation examples, please visit the official repository and community forums. We continually update and improve this library to meet the needs of developers and users of modern WhatsApp automation solutions.

Thank you for choosing WhatsApp Baileys as your WhatsApp automation solution!


Contact Developer

For questions, support, or collaboration, feel free to contact the developer:

Contributors outside the Baileys code

Thanks to the following awesome contributors who help improve this project