
Product
Socket Threat Intel Now Shows Which Malware Campaigns Were Blocked or Detected
Socket Threat Intel now shows which malware campaigns were blocked or detected in your organization, with links to scans and Firewall events.
kevinx-baileys
Advanced tools
KevinX Baileys — a WebSockets library for interacting with WhatsApp Web (multi-device, pairing code, interactive messages, newsletter, auto-reconnect, send queue, typings).
A fast, stable WhatsApp Web (multi-device) library over WebSocket — no browser required.
KevinX Baileys is a modified Baileys build for developers who want to build WhatsApp bots, automation and integrations directly over WebSocket. It adds a custom pairing code, interactive messages, action buttons, newsletter support and extra message options on top of the Baileys core.
Maintained by KevinX — Telegram: @kevinxddd
npm install kevinx-baileys
Use it as a drop-in replacement for @whiskeysockets/baileys by aliasing it in your package.json:
{
"dependencies": {
"@whiskeysockets/baileys": "npm:kevinx-baileys"
}
}
Requires Node.js 20 or newer (Node 21 and 22+ are supported).
KevinX Baileys is an ES module:
import makeWASocket, {
useMultiFileAuthState,
fetchLatestBaileysVersion,
Browsers,
DisconnectReason
} from 'kevinx-baileys'
From CommonJS, use dynamic import (or require() directly on Node 20.19+ / 22.12+):
const { default: makeWASocket, useMultiFileAuthState } = await import('kevinx-baileys')
printQRInTerminal is deprecated — listen to connection.update and render the QR yourself (for example with the qrcode-terminal package):
import qrcode from 'qrcode-terminal'
const { state, saveCreds } = await useMultiFileAuthState('session')
const { version } = await fetchLatestBaileysVersion()
const sock = makeWASocket({
version,
auth: state,
browser: Browsers.ubuntu('Chrome')
})
sock.ev.on('creds.update', saveCreds)
sock.ev.on('connection.update', ({ connection, lastDisconnect, qr }) => {
if (qr) qrcode.generate(qr, { small: true })
if (connection === 'close') {
const code = lastDisconnect?.error?.output?.statusCode
if (code !== DisconnectReason.loggedOut) {
// reconnect here (re-run your start function)
}
}
})
const { state, saveCreds } = await useMultiFileAuthState('session')
const { version } = await fetchLatestBaileysVersion()
const sock = makeWASocket({
version,
auth: state,
browser: Browsers.ubuntu('Chrome')
})
sock.ev.on('creds.update', saveCreds)
if (!sock.authState.creds.registered) {
const number = '628XXXXXXXXXX' // country code, digits only
const code = await sock.requestPairingCode(number.trim())
console.log('Your pairing code:', code)
}
Pass your own code as the second argument — it must be exactly 8 characters. If you omit it, the default KEVINXWA is used.
const code = await sock.requestPairingCode(number.trim(), 'KEVINX01')
console.log('Your pairing code:', code)
ptcpptcp: true sends the message without syncing it to your own other linked devices (same behaviour as noSelfSync).
await sock.sendMessage(m.chat, { text: 'KevinX Baileys' }, { ptcp: true })
Everything below is additive. Existing code keeps working, and no existing socket method is replaced.
makeKevinXSocket() - auto-reconnect in one callimport { makeKevinXSocket } from 'kevinx-baileys'
const bot = await makeKevinXSocket({
sessionPath: 'session',
pairingNumber: '628XXXXXXXXXX', // omit to use QR (see onQR)
onSocket: (sock) => {
// runs on EVERY (re)connect - attach your listeners here
sock.ev.on('messages.upsert', async ({ messages }) => {
const m = messages[0]
if (!m.message || m.key.fromMe) return
await sock.reply(m, 'pong')
})
},
onPairingCode: (code) => console.log('Pairing code:', code),
onReconnecting: ({ attempt, waitMs }) => console.log(`reconnect #${attempt} in ${waitMs}ms`)
})
bot.sock // always the current socket
await bot.stop()
It reconnects with exponential backoff (2s, 4s, 8s ... max 60s, with jitter) and does not reconnect after loggedOut, connectionReplaced (another session took over) or forbidden, because reconnecting there only loops. restartRequired (normal after pairing) reconnects immediately. Tune it with reconnect: { minDelay, maxDelay, factor, jitter, maxRetries }.
Reconnecting reduces "connection closed" problems. No library can promise you will never be disconnected or never be banned.
Other options: auth (custom auth state, see below), socketConfig, cleanup, checkUpdate, autoFollowChannels, onQR, onOpen, onClose, onLoggedOut, onError.
const code = await sock.pair('628XXXXXXXXXX') // waits until ready, retries by itself
const code2 = await sock.pair('628XXXXXXXXXX', 'KEVINX01') // custom 8-char code
await sock.reply(m, 'text') // quotes m
await sock.reply(m, { image: { url }, caption }) // any content
await sock.sendWithTyping(jid, 'hello', { typingMs: 1500 }) // "typing..." first, length-based if typingMs is omitted
sendText, sendImage, sendVideo, sendAudio and sendDocument already existed and keep their signatures.
const results = await sock.broadcast(['628111@s.whatsapp.net', '628222@s.whatsapp.net'], { text: 'Hello' }, undefined, {
onProgress: ({ done, total }) => console.log(done, '/', total)
})
// [{ jid, ok: true, message } | { jid, ok: false, error }]
// per-recipient content
await sock.broadcast(jids, (jid) => ({ text: `Hi ${jid.split('@')[0]}` }))
sock.queue.pause(); sock.queue.resume(); sock.queue.clear()
Messages go out one by one with a random 1.5 - 4 s gap (makeWASocket({ sendQueue: { minDelay, maxDelay, retries } })). This reduces burst sending. It does not guarantee you will not be flagged or banned.
await sock.sendStatusText('Good morning', ['628111', '628222'])
await sock.sendStatusImage('https://example.com/a.jpg', ['628111'], 'caption')
await sock.sendStatusVideo('./clip.mp4', ['628111'])
Only the listed contacts see it. Your own number is added automatically.
import { backupSession, restoreSession, cleanSession } from 'kevinx-baileys'
await backupSession('session', 'backups/session-backup-1.kxsession', { keep: 5 })
await restoreSession('backups/session-backup-1.kxsession', 'session')
await cleanSession('session', { maxAgeDays: 3, dryRun: true }) // prunes old re-creatable cache files only
cleanSession never touches creds.json. By default it only removes old sender-key-memory-* and device-list-* files. Add session-* or pre-key-* to patterns only if you accept that some chats may need to renegotiate keys. Or let makeKevinXSocket({ cleanup: { maxAgeDays: 3, intervalHours: 24 } }) do it.
import { useMongoAuthState, useRedisAuthState, makeKevinXSocket } from 'kevinx-baileys'
import { MongoClient } from 'mongodb'
const client = await new MongoClient(process.env.MONGO_URL).connect()
const auth = await useMongoAuthState(client.db('wa').collection('auth'), { sessionId: 'bot1' })
const bot = await makeKevinXSocket({ auth, pairingNumber: '628XXXXXXXXXX' })
// Redis (ioredis or node-redis v4+)
const auth2 = await useRedisAuthState(redisClient, { prefix: 'wa:bot1' })
You bring your own driver (mongodb, ioredis or redis), so this library adds no extra dependency. auth.clear() deletes the stored session.
await sock.channel.info('https://whatsapp.com/channel/XXXX')
await sock.channel.follow('https://whatsapp.com/channel/XXXX')
await sock.channel.react('120363...@newsletter', serverId, '🔥')
await sock.channel.followMany([...links])
Nothing is followed unless you call it. autoFollowChannels in makeKevinXSocket is an empty list by default.
The group metadata cache is on by default (5 minutes, refreshed on group events). Turn it off with makeWASocket({ groupCache: false }), or pass your own cachedGroupMetadata.
await sock.tagAll(groupJid, 'Meeting at 8') // mentions everyone
await sock.hidetag(groupJid, 'Read this')
const meta = await sock.getGroupMetadata(groupJid)
Opt-in. Run with KEVINX_CHECK_UPDATE=true (or makeKevinXSocket({ checkUpdate: true })) to print a notice when a newer version exists on npm. It never installs anything.
import { checkForUpdate } from 'kevinx-baileys'
const { updateAvailable, latestVersion } = await checkForUpdate()
Typings ship with the package (lib/index.d.ts). New features and the most used core API are fully typed. Other exports are typed as any for now so autocomplete still knows their names.
An ASCII banner is printed once when the library is loaded. To disable it:
KEVINX_BANNER=false node index.js
MessageBuilder / MB)makeKevinXSocket), pairing helper, send queue / broadcastFor questions, support, bug reports and updates, contact the developer on Telegram.
Released under the MIT License. Based on Baileys by Rajeh Taher / WhiskeySockets.
KevinX Baileys
Maintained by @kevinxddd • t.me/kevinstore1122
FAQs
KevinX Baileys — a WebSockets library for interacting with WhatsApp Web (multi-device, pairing code, interactive messages, newsletter, auto-reconnect, send queue, typings).
We found that kevinx-baileys demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Product
Socket Threat Intel now shows which malware campaigns were blocked or detected in your organization, with links to scans and Firewall events.

Security News
Fixes for eMudhra and Brotli are out. Getting them everywhere they’re needed means tracking down bundled libraries, runtimes, and certificate stores.

Threat Research
/Security News
Socket uncovered secret-stealing workflows that ran in LiteLLM’s GitHub repository 11 days before the supply chain attack on PyPI and Docker.