Getting Started

From zero to a connected bot in a few minutes.

Requirements

RequirementDetails
Node.js>= 20.0.0 (enforced by the package via engines)
A WhatsApp numberAn active number to pair as the bot (multi-device)
Module systemThe package is type: module โ€” use import (ESM)

Install

npm i aunubaileys

Core dependencies (ws, pino, libsignal, protobufjs, and more) install automatically. Optional peers: sharp, jimp, link-preview-js, audio-decode โ€” install only what your features need (e.g. image processing).

Your first bot

import makeWASocket, {
  useMultiFileAuthState,
  makeInMemoryStore,
  DisconnectReason
} from 'aunubaileys'
import { Boom } from '@hapi/boom'

const store = makeInMemoryStore({})

async function start() {
  const { state, saveCreds } = await useMultiFileAuthState('auth')
  const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true // or use a pairing code โ€” see Connection
  })
  store.bind(sock.ev)
  sock.ev.on('creds.update', saveCreds)

  sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
    if (connection === 'close') {
      const loggedOut = (lastDisconnect?.error instanceof Boom)
        && lastDisconnect.error.output.statusCode === DisconnectReason.loggedOut
      if (!loggedOut) start() // reconnect
    }
  })

  sock.ev.on('messages.upsert', async ({ messages }) => {
    const m = messages[0]
    if (m.key.fromMe) return
    await sock.sendMessage(m.key.remoteJid, { text: 'Hello from AunuBaileys ๐Ÿ–ค' })
  })
}
start()
The auth/ folder is your session. Never delete or share it โ€” it holds the linked device's credentials. In AunuBaileys, session files are written atomically (since v1.0.2), so a crashed process can't leave a half-written credential file behind.

Next steps

๐Ÿ“ฑ Connection & Pairing

QR, custom pairing codes, and the right reconnect pattern.

Open โ†’

โœ‰๏ธ Sending Messages

Text, media, stickers, StickerPack, albums, and the AI label.

Open โ†’

๐Ÿ›ก๏ธ AunuAntiBan

Turn on account protection before running a bot seriously.

Open โ†’