Multiple accounts
Run several numbers in one process: one client per account, each with its own session folder.
TypeScript · ESM · MIT
No Puppeteer, no headless Chromium. whatsweb speaks the native Multi-Device protocol directly over a WebSocket, wrapped in a fully-typed, bot-friendly API.
Features
Everything you need to build WhatsApp bots and integrations.
A fraction of the RAM and startup time of Puppeteer-based clients.
command, hears, middleware and a rich Context.
Event callbacks or a linear for await async iterator.
Path, http(s)/S3 URL, Buffer or stream, with auto type detection.
Polls, mentions, stickers, contacts, edit / delete / forward.
Metadata, participants, invite links, create / join / leave.
Presence, profile pictures, status and block list.
Run many numbers in one process, each with its own session.
State, history and ask, plus a neutral toMessages() to plug
in your own LLM or agent.
Auto-reconnect with backoff and optional send rate-limiting.
Install
Works with npm, pnpm and Bun. Requires Node ≥ 20 (or Bun) and ESM.
Add "type": "module" to your package.json. Baileys 7 (and this
SDK) are ESM-only. Bun can also run the TypeScript examples directly, no build step.
Examples
For the things you'll actually build. Hover a block to copy it.
Setup & sessions
Run several numbers in one process: one client per account, each with its own session folder.
Credentials live on disk, so you only scan once. Point them wherever you like.
Link an account with an 8-character code instead of scanning a QR.
Turn off the terminal output and do what you want with the raw value: a PNG, a web page, a Slack message.
Stay online with backoff, and space out sends to reduce ban risk.
Silent by default. Pass a pino-compatible logger when you need to see the wire.
Close the socket without losing the session, or unlink the device for good.
Sending
Images, voice notes, documents and locations. Sources can be a path, URL or Buffer.
Point at any URL and the media kind (image/video/audio/document) is detected for you.
Mentions, polls, stickers and contact cards.
Every send has a reply counterpart on the context, already addressed to the sender.
Manage messages after sending them.
Save incoming attachments to disk.
Set the recipient once and keep calling methods on it, no JIDs to repeat.
Routing & flow
Prefer a linear flow? Iterate incoming messages instead of registering callbacks.
Choose your own command prefixes, give a handler several names, and read RegExp captures off the context.
Compose behavior; in groups, only react to commands.
Mark as seen, hold the typing indicator while you work, or let the SDK time it.
Pause a handler until the same person answers, or wait anywhere for a message that matches.
Every event is strongly typed.
Conversations & state
Remember context per user, persisted through a pluggable store (in-memory by default, or Redis/DB).
Prompt the user, await their replies, and store the answers: a full signup flow.
Ask yes/no and get a boolean. Accepted answers are configurable (defaults cover en/es plus 👍/👎).
Recent messages are kept per chat, with a configurable window you can clear at any time.
Implement three methods to back conversation state with Redis, Postgres or anything else.
whatsweb is unopinionated about LLMs. It hands you the transcript, you drive the model (here, the Vercel AI SDK).
Groups & contacts
A fluent handle for every group operation.
Set your presence and profile, read other people's, manage the block list.
Find out whether a number is on WhatsApp before sending, and resolve its LID.
Run locally
Clone the repo and run any example with your package manager of choice.
Other examples: example:bot, example:async,
example:pair, example:send. Bun runs the
examples/*.ts files directly, no tsx needed.
Every class, method, event and option, auto-generated from the source.
Open the documentation