Skip to main content

Installation

Get started with Baileys by installing it via your preferred package manager.

Requirements

Before installing Baileys, ensure your environment meets these requirements:
  • Node.js: Version 20.0.0 or higher
  • Package Manager: npm, yarn, or pnpm
Baileys requires Node.js 20+ due to dependencies on modern JavaScript features and native modules.

Install Baileys

Choose your preferred package manager to install Baileys:
npm install @whiskeysockets/baileys

Install the edge version

If you need the latest features and bug fixes (with no stability guarantee), you can install directly from GitHub:
npm install github:WhiskeySockets/Baileys
The edge version may contain breaking changes and unstable features. Use it only if you need specific unreleased functionality.

Optional dependencies

Baileys includes several optional peer dependencies that enable additional features:

Media processing

For automatic thumbnail generation and image processing:
npm install sharp
# or
npm install jimp
sharp is recommended over jimp for better performance and image quality.
To enable automatic link preview generation in messages:
npm install link-preview-js

Audio processing

For audio decoding and processing:
npm install audio-decode

Additional tools

FFmpeg (for video thumbnails)

To generate thumbnails for video messages, install FFmpeg on your system:
sudo apt update
sudo apt install ffmpeg

Audio conversion

For audio messages to work properly across all devices, you need to convert them to Opus format. Install FFmpeg (shown above) and use these flags:
ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg
The required flags are:
  • codec: libopus - OGG file format
  • ac: 1 - One audio channel (mono)
  • avoid_negative_ts make_zero - Timestamp handling

Import Baileys

Once installed, import Baileys in your TypeScript or JavaScript files:
import makeWASocket from '@whiskeysockets/baileys'
For specific features, you can import additional utilities:
import makeWASocket, { 
  useMultiFileAuthState,
  DisconnectReason,
  fetchLatestBaileysVersion,
  makeCacheableSignalKeyStore
} from '@whiskeysockets/baileys'

Verify installation

Create a simple test file to verify everything is working:
test.ts
import makeWASocket, { useMultiFileAuthState } from '@whiskeysockets/baileys'

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

const sock = makeWASocket({
  auth: state
})

sock.ev.on('connection.update', (update) => {
  const { qr } = update
  if(qr) {
    console.log('QR Code:', qr)
  }
})

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

console.log('Baileys is ready!')
Run it with:
npx tsx test.ts
If you see “Baileys is ready!” and a QR code, your installation is successful.

Next steps

Quick start guide

Learn how to create your first WhatsApp bot with Baileys

Build docs developers (and LLMs) love