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

shiraori-baileys

v1.0.7

Published

A modern WhatsApp Web library — Carousel, Buttons, CTA, List, Pairing Code, FastMode, Anti Bad Session

Readme

shiraori-baileys

Library WhatsApp Web modern berbasis TypeScript Ringan · Fitur Lengkap · Siap Produksi

TypeScript Node.js License Version


✨ Apa itu shiraori-baileys?

shiraori-baileys adalah library open-source untuk menghubungkan aplikasi Node.js ke WhatsApp Web. Dibangun dari awal dengan TypeScript, library ini hadir dengan fitur-fitur interaktif modern yang tidak ada di library sejenis — termasuk Carousel Image, CTA Buttons, Pairing Code, FastMode, dan Anti Bad Session.

⚡ Dirancang untuk bot, automation, dan aplikasi bisnis yang membutuhkan pengiriman pesan WhatsApp yang andal dan cepat.


🚀 Keunggulan

| Fitur | shiraori-baileys | Library Lain | |---|:---:|:---:| | 🔑 Pairing Code (tanpa QR) | ✅ | ❌ | | 🎠 Carousel Image | ✅ | ❌ | | 🌐 CTA URL Button | ✅ | ❌ | | 📋 CTA Copy Button | ✅ | ❌ | | 📞 CTA Call Button | ✅ | ❌ | | 📃 List Message | ✅ | ⚠️ | | ⚡ FastMode Queue | ✅ | ❌ | | 🛡️ Anti Bad Session | ✅ | ❌ | | 📘 Full TypeScript | ✅ | ⚠️ | | 🔄 Auto Reconnect | ✅ | ⚠️ |


📦 Instalasi

npm install shiraori-baileys
yarn add shiraori-baileys

Requirements: Node.js ≥ 18.0.0


🔌 Cara Koneksi

shiraori-baileys mendukung 2 metode koneksi. Pilih sesuai kebutuhan:


Metode 1 — QR Code (Scan via Kamera)

Metode klasik: QR code tampil di terminal, scan dengan WhatsApp.

import { makeWASocket, useMultiFileAuthState } from 'shiraori-baileys'

async function start() {
  const { state, saveCreds } = await useMultiFileAuthState('./session')

  const sock = makeWASocket(state, {
    printQRInTerminal: true,  // QR otomatis tampil di terminal
    antiBadSession: true,
    logLevel: 'info',
  })

  // Simpan kredensial saat ada perubahan
  sock.on('creds.update', saveCreds)

  sock.on('connection.update', ({ connection, qr }) => {
    if (qr) {
      console.log('📱 Scan QR di atas dengan WhatsApp kamu')
    }
    if (connection === 'open') {
      console.log('✅ Berhasil terhubung ke WhatsApp!')
    }
    if (connection === 'close') {
      console.log('🔴 Koneksi terputus, mencoba reconnect...')
    }
  })

  // Tangkap pesan masuk
  sock.on('messages.upsert', async ({ messages, type }) => {
    if (type !== 'notify') return
    const msg = messages[0]
    if (!msg.key.fromMe) {
      const jid = msg.key.remoteJid!
      await sock.sendText(jid, 'Halo! 👋 Bot aktif.')
    }
  })
}

start()

Cara kerja:

  1. Jalankan program
  2. QR code muncul di terminal
  3. Buka WhatsApp → Perangkat TertautTautkan Perangkat
  4. Scan QR → selesai ✅

Metode 2 — Pairing Code (Tanpa Kamera) ⭐ Direkomendasikan

Login menggunakan kode 8 digit — tidak perlu scan QR sama sekali.

import { makeWASocket, useMultiFileAuthState } from 'shiraori-baileys'

async function start() {
  const { state, saveCreds } = await useMultiFileAuthState('./session')

  const sock = makeWASocket(state, {
    usePairingCode: true,
    phoneNumber: '6281234567890',  // ← nomor WA kamu (tanpa + dan spasi)
    printQRInTerminal: false,
    antiBadSession: true,
  })

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

  sock.on('connection.update', ({ connection, pairingCode }) => {
    if (pairingCode) {
      console.log('┌─────────────────────────────┐')
      console.log('│  🔑 KODE PAIRING WHATSAPP   │')
      console.log(`│        ${pairingCode}         │`)
      console.log('└─────────────────────────────┘')
      console.log('')
      console.log('📌 Cara memasukkan kode:')
      console.log('   1. Buka WhatsApp di HP')
      console.log('   2. Ketuk ⋮ → Perangkat Tertaut')
      console.log('   3. Tautkan Perangkat → Tautkan dengan Nomor Telepon')
      console.log('   4. Masukkan kode di atas')
    }
    if (connection === 'open') {
      console.log('✅ Berhasil terhubung via Pairing Code!')
    }
  })

  sock.on('messages.upsert', async ({ messages, type }) => {
    if (type !== 'notify') return
    const msg = messages[0]
    if (!msg.key.fromMe) {
      const jid = msg.key.remoteJid!
      await sock.sendText(jid, 'Halo! 👋')
    }
  })
}

start()

Cara kerja:

  1. Jalankan program, kode 8 digit muncul di terminal
  2. Buka WhatsApp → ⋮ MenuPerangkat Tertaut
  3. Tautkan PerangkatTautkan dengan Nomor Telepon
  4. Masukkan kode → selesai ✅

Catatan: Kode berlaku selama ±2 menit. Jika expired, restart program untuk mendapat kode baru.


Metode 3 — connectToWhatsApp (Helper Lengkap)

Wrapper high-level dengan auto reconnect, event callbacks, dan pairing code sudah terintegrasi.

import { connectToWhatsApp, useMultiFileAuthState } from 'shiraori-baileys'

async function start() {
  const { state, saveCreds } = await useMultiFileAuthState('./session')

  const sock = connectToWhatsApp(state, {
    // Koneksi
    printQRInTerminal: true,
    // usePairingCode: true,
    // phoneNumber: '6281234567890',

    // Stabilitas
    antiBadSession: true,
    autoReconnect: true,
    maxReconnectRetries: 5,

    // Performa
    fastMode: true,
    fastModeDelay: 120,

    // Event callbacks
    onQR: (qr) => {
      console.log('QR siap untuk di-scan')
    },
    onPairingCode: (code) => {
      console.log('🔑 Kode Pairing:', code)
    },
    onConnected: async (sock) => {
      console.log('✅ Terhubung!')
    },
    onDisconnected: (reason, willReconnect) => {
      console.log(`Terputus: ${reason} | Reconnect: ${willReconnect}`)
    },
    onMessage: (messages) => {
      for (const msg of messages) {
        if (!msg.key.fromMe) {
          console.log('Pesan masuk:', msg.message?.conversation)
        }
      }
    },
  })

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

start()

💬 Fitur Pesan Interaktif

📝 Teks Biasa

// Kirim teks
await sock.sendText(jid, 'Halo dunia! 🌏')

// Balas pesan (quoted)
await sock.sendText(jid, 'Ini balasan!', { quoted: msg })

🔘 Buttons (Quick Reply)

await sock.sendButtons(jid, {
  text: 'Pilih menu yang kamu inginkan:',
  footer: 'shiraori-baileys',
  buttons: [
    { id: 'menu_makanan', label: '🍔 Makanan' },
    { id: 'menu_minuman', label: '🥤 Minuman' },
    { id: 'menu_dessert', label: '🍰 Dessert' },
  ],
})

⚠️ Maksimal 3 tombol. Untuk lebih dari 3, gunakan sendInteractiveMessage.


🌐 CTA URL — Tombol Buka Website

await sock.sendCtaUrl(jid, {
  body: 'Kunjungi website kami untuk promo terbaru!',
  footer: 'shiraori-baileys',
  label: '🌐 Buka Website',
  url: 'https://example.com',
})

📋 CTA Copy — Tombol Salin Teks

await sock.sendCtaCopy(jid, {
  body: 'Gunakan kode promo ini untuk diskon 50%! 🎉',
  footer: 'Berlaku hingga 31 Desember',
  label: '📋 Salin Kode Promo',
  copyCode: 'HEMAT50',
})

📞 CTA Call — Tombol Telepon

await sock.sendCtaCall(jid, {
  body: 'Ada pertanyaan? Hubungi tim CS kami langsung!',
  footer: 'Senin–Jumat · 09.00–17.00 WIB',
  label: '📞 Hubungi CS',
  phoneNumber: '+628123456789',
})

📃 List Message

await sock.sendListMessage(jid, {
  title: '🍽️ Menu Restoran',
  description: 'Pilih menu favorit kamu:',
  buttonText: 'Lihat Semua Menu',
  footer: 'Free ongkir min. order Rp 50.000',
  sections: [
    {
      title: '🍔 Makanan Utama',
      rows: [
        { id: 'nasi_goreng', title: 'Nasi Goreng Special', description: 'Rp 25.000' },
        { id: 'mie_goreng',  title: 'Mie Goreng Seafood',  description: 'Rp 28.000' },
        { id: 'ayam_bakar',  title: 'Ayam Bakar Kecap',    description: 'Rp 35.000' },
      ],
    },
    {
      title: '🥤 Minuman',
      rows: [
        { id: 'es_teh',     title: 'Es Teh Manis',  description: 'Rp 5.000'  },
        { id: 'jus_alpukat', title: 'Jus Alpukat',  description: 'Rp 15.000' },
        { id: 'kopi_susu',  title: 'Kopi Susu',     description: 'Rp 18.000' },
      ],
    },
  ],
})

🎠 Carousel Image

Kirim beberapa kartu sekaligus, masing-masing dengan gambar dan tombol berbeda.

await sock.sendCarousel(jid, {
  body: '🛍️ Produk Terbaru Kami',
  footer: 'Tap kartu untuk detail',
  cards: [
    {
      image: uploadedImage1,   // WAImageMessage dari hasil upload media
      body: '*Nike Air Max*\nRp 1.200.000\n⭐ 4.8 / 5 · Terjual 2.3k',
      buttons: [
        { type: 'quick_reply', id: 'buy_nike',   label: '🛒 Beli Sekarang' },
        { type: 'cta_url',     label: '🔍 Detail', url: 'https://example.com/nike' },
      ],
    },
    {
      image: uploadedImage2,
      body: '*Adidas Ultra Boost*\nRp 1.500.000\n⭐ 4.9 / 5 · Terjual 1.8k',
      buttons: [
        { type: 'quick_reply', id: 'buy_adidas',  label: '🛒 Beli Sekarang' },
        { type: 'cta_url',     label: '🔍 Detail', url: 'https://example.com/adidas' },
      ],
    },
    {
      image: uploadedImage3,
      body: '*Vans Old Skool*\nRp 850.000\n⭐ 4.7 / 5 · Terjual 3.1k',
      buttons: [
        { type: 'quick_reply', id: 'buy_vans',   label: '🛒 Beli Sekarang' },
        { type: 'cta_url',     label: '🔍 Detail', url: 'https://example.com/vans' },
      ],
    },
  ],
})

🎛️ Interactive Message — Kombinasi Semua Tombol

await sock.sendInteractiveMessage(jid, {
  body: 'Selamat datang di layanan kami! Pilih opsi di bawah:',
  footer: 'shiraori-baileys · Powered by Node.js',
  header: {
    title: '🏪 Toko Online',
    subtitle: 'Belanja mudah, cepat, dan aman',
  },
  buttons: [
    { type: 'quick_reply', id: 'catalog',  label: '📦 Lihat Katalog'             },
    { type: 'cta_url',     label: '🌐 Website',   url: 'https://example.com'     },
    { type: 'cta_copy',    label: '📋 Kode Promo', copyCode: 'DISKON20'          },
    { type: 'cta_call',    label: '📞 Hubungi CS', phoneNumber: '+628123456789'  },
  ],
})

⚡ FastMode

FastMode mengoptimalkan pengiriman pesan massal dengan sistem queue cerdas — tidak perlu khawatir rate limit atau pesan terkirim ganda.

const sock = makeWASocket(state, {
  fastMode: true,
  fastModeDelay: 100,   // jeda antar pesan dalam ms
})

// Kirim ke banyak nomor sekaligus — otomatis di-queue
const targets = ['[email protected]', '[email protected]', ...]
await Promise.all(
  targets.map((jid, i) => sock.sendText(jid, `Halo, ini pesan ke-${i + 1}! 📢`))
)

// Cek statistik queue
const stats = sock.getFastModeStats()
console.log(stats)
// {
//   queueSize: 0,
//   activeJids: 2,
//   totalSent: 150,
//   totalFailed: 0,
//   isProcessing: false
// }

// Batalkan semua pesan yang sedang antri
sock.clearFastModeQueue()

Konfigurasi FastMode:

fastMode: true,
fastModeDelay: 100,      // delay global antar batch (ms)
// Opsi lanjutan via FastMode class langsung:
// sameJidDelay: 300     // delay pesan ke JID yang sama
// concurrency: 3        // maks pengiriman bersamaan
// maxQueueSize: 500     // maks antrian

🛡️ Anti Bad Session

Secara otomatis mendeteksi session yang korup dan membersihkannya, sehingga bot tidak perlu restart manual.

const sock = makeWASocket(state, {
  antiBadSession: true,
  sessionDir: './session',
  maxReconnectRetries: 5,
})

Yang terjadi saat session rusak:

[shiraori] AntiBadSession: bad session detected (attempt 1/5)
[shiraori] AntiBadSession: session cleared
[shiraori] Reconnecting (1/5) in 3000ms...
→ QR / Pairing Code baru digenerate otomatis
→ Setelah login ulang, counter retry direset

⚙️ Konfigurasi Lengkap

const sock = makeWASocket(state, {
  // ── Koneksi ──────────────────────────────────
  printQRInTerminal: true,          // tampilkan QR di terminal
  browser: ['MyBot', 'Chrome', '120.0.0'],  // identitas browser
  usePairingCode: false,            // gunakan pairing code
  phoneNumber: '',                  // nomor HP (wajib jika usePairingCode: true)
  markOnlineOnConnect: true,        // tandai online saat konek

  // ── Session & Keamanan ────────────────────────
  antiBadSession: true,             // aktifkan anti bad session
  sessionDir: './session',          // lokasi penyimpanan session
  autoReconnect: true,              // reconnect otomatis
  maxReconnectRetries: 5,           // maksimal percobaan reconnect
  reconnectInterval: 3000,          // jeda antar reconnect (ms)

  // ── Performa ──────────────────────────────────
  fastMode: false,                  // aktifkan fastmode
  fastModeDelay: 100,               // delay antar pesan (ms)

  // ── Logging ───────────────────────────────────
  logLevel: 'info',                 // 'silent'|'error'|'warn'|'info'|'debug'|'trace'
})

📁 Struktur Proyek

shiraori-baileys/
├── src/
│   ├── core/
│   │   ├── socket.ts          ← WASocket — class utama dengan semua metode send
│   │   └── make-socket.ts     ← makeWASocket() & connectToWhatsApp() factory
│   ├── messages/
│   │   └── interactive.ts     ← Builder: Carousel, Buttons, CTA, List
│   ├── utils/
│   │   ├── session.ts         ← useMultiFileAuthState & AntiBadSession
│   │   ├── fastmode.ts        ← FastMode queue engine
│   │   ├── logger.ts          ← Logger berwarna dengan level hierarchy
│   │   └── pairing.ts         ← PairingCodeManager, validasi nomor
│   ├── crypto/
│   │   └── index.ts           ← Key generation, HKDF, AES-256, HMAC-SHA256
│   ├── types/
│   │   └── index.ts           ← Semua TypeScript types & interfaces
│   └── index.ts               ← Public API exports
├── dist/                      ← Compiled JavaScript (setelah npm run build)
├── examples/
│   └── basic.ts               ← 12 contoh penggunaan lengkap
├── package.json
├── tsconfig.json
└── README.md

🔧 Scripts

npm run build       # compile TypeScript → dist/
npm run dev         # jalankan src/index.ts langsung (ts-node)
npm run example     # jalankan examples/basic.ts
npm run clean       # hapus folder dist/

❓ FAQ

Q: Apakah nomor saya bisa kena banned? A: Risiko ada jika digunakan untuk spam. Gunakan dengan bijak — jangan kirim pesan massal tanpa persetujuan penerima. FastMode sudah dirancang untuk mengurangi risiko flood detection.

Q: Pairing code expired sebelum saya sempat memasukkan? A: Kode berlaku ±2 menit. Restart program untuk mendapat kode baru.

Q: Session sering disconnect/korup? A: Aktifkan antiBadSession: true dan autoReconnect: true. Library akan otomatis membersihkan dan reconnect.

Q: Bisa digunakan untuk WhatsApp Business? A: Ya, bisa digunakan dengan nomor WhatsApp Business biasa. Untuk WhatsApp Business API resmi, gunakan layanan Meta.


⚠️ Disclaimer

Library ini bukan produk resmi WhatsApp atau Meta. Penggunaan library ini sepenuhnya tanggung jawab pengguna. Penulis tidak bertanggung jawab atas:

  • Pemblokiran atau banned akun WhatsApp
  • Pelanggaran Terms of Service WhatsApp
  • Penyalahgunaan untuk spam atau konten ilegal

Gunakan secara etis dan bertanggung jawab.


📄 License

MIT © 2024 — shiraori-baileys


Dibuat dengan ❤️ menggunakan TypeScript

⭐ Star di GitHub · 🐛 Laporkan Bug · 💡 Request Fitur