Skip to main content

Installation

Baileys is available as an npm package and can be installed using your preferred package manager.

Requirements

Before installing Baileys, ensure you have:
  • Node.js 20.0.0 or higher - Required for running Baileys
  • A package manager (npm, yarn, or pnpm)

Install the stable version

The stable version is recommended for production use:
npm install @whiskeysockets/baileys

Install the edge version

The edge version includes the latest features and fixes, but may be less stable:
npm install github:WhiskeySockets/Baileys
The edge version is built directly from the GitHub repository and may contain breaking changes or bugs. Use it only if you need the absolute latest features or fixes.

Import in your project

Once installed, import Baileys in your TypeScript or JavaScript files:
import makeWASocket from '@whiskeysockets/baileys'
For CommonJS projects:
const { default: makeWASocket } = require('@whiskeysockets/baileys')

Optional dependencies

Baileys has several optional peer dependencies that enable additional functionality: To enable automatic link preview generation in messages:
npm install link-preview-js

Media thumbnail generation

For automatic thumbnail generation in image and sticker messages:
npm install jimp
# or
npm install sharp
For video thumbnail generation, you’ll also need ffmpeg installed on your system. Install it using your system’s package manager (e.g., apt install ffmpeg on Ubuntu).

Audio decoding

For advanced audio processing:
npm install audio-decode

Verify installation

To verify that Baileys is installed correctly, create a simple test file:
test.ts
import makeWASocket from '@whiskeysockets/baileys'

const sock = makeWASocket({
  printQRInTerminal: true
})

console.log('Baileys loaded successfully!')
Run it with:
node test.ts
# or with tsx for TypeScript
npx tsx test.ts
If you see the success message, Baileys is installed correctly!

Next steps

Quickstart guide

Build your first WhatsApp bot with Baileys

API documentation

Explore all available methods and types

Build docs developers (and LLMs) love