Skip to main content
Every Baileys connection starts by calling makeWASocket with a SocketConfig object. Most options have sensible defaults defined in DEFAULT_CONNECTION_CONFIG, so you only need to provide the ones that matter for your use case. This page walks through every option you are likely to configure in a real application.

Required options

auth

The only truly required field. You must pass an AuthenticationState object containing your credentials and Signal key store. Use useMultiFileAuthState to load credentials from disk during development, and replace it with a database-backed implementation for production.
When a message is sent or received, Signal sessions update and authState.keys.set() is called. If you do not persist those key updates immediately, messages will fail to decrypt on your next connection. useMultiFileAuthState handles this automatically; any custom implementation must too.

Identity and browser

browser

Controls how Baileys identifies itself to WhatsApp. The type is WABrowserDescription, which is a [platform, browserName, version] tuple. Use the Browsers constant instead of writing the tuple manually — this is also the name that appears in WhatsApp’s Linked Devices list.
A few ready-made presets are available: The browser you choose also affects how much history WhatsApp sends on first sync. Desktop identities (macOS or Windows) receive significantly more history than mobile ones.

Receiving full message history

By default, Baileys connects with a Chrome browser profile, which limits how much history WhatsApp delivers on the initial sync. syncFullHistory is already true by default — the key step is switching the browser preset to Browsers.macOS('Desktop'), which WhatsApp treats as a desktop client eligible for extended history.
History messages arrive asynchronously via the messaging-history.set event after the connection opens. See Sync chat history for details on consuming the payload.
Requesting full history can significantly increase startup time and memory usage on accounts with large chat histories.

logger

Accepts any pino-compatible logger. Pass a logger with level: 'debug' to see every binary frame Baileys sends and receives — useful when debugging protocol issues.
Use logger.child({ class: 'baileys' }) to namespace Baileys log lines separately from your application logs, matching the pattern used in DEFAULT_CONNECTION_CONFIG.

Connection behavior

markOnlineOnConnect

Default: true When true, Baileys marks itself as an online/active client the moment the socket connects. WhatsApp treats an active web session as a foreground device, so the primary phone stops sending push notifications. Set this to false if you want the phone to continue receiving notifications while your bot or integration runs in the background.

syncFullHistory

Default: true Requests the phone to deliver the full chat history on first connection. This is delivered asynchronously via the messaging-history.set event. Full history syncs can be large; if you only need recent messages, set this to false.

printQRInTerminal

This option is deprecated and has been removed from Baileys. Use the connection.update event to read the qr field and render it yourself with a library such as qrcode-terminal.

Message reliability

getMessage

A callback that takes a WAMessageKey and returns the corresponding proto.IMessage (or undefined). Baileys calls this in two situations:
  1. Message retries — when a message fails to decrypt on the first attempt, Baileys requests a resend. It needs the original plaintext to re-encrypt it.
  2. Poll vote decryptionmessages.update events for polls require the original poll creation message to aggregate votes.
Without this callback, both retry delivery and poll aggregation silently fail.

msgRetryCounterCache

A CacheStore used to count how many times Baileys has retried sending a specific message. This prevents infinite retry loops. Use a NodeCache instance (from @cacheable/node-cache) or any object that satisfies the CacheStore interface.
Keep this cache outside your startSock function so the retry counts survive socket restarts.

maxMsgRetryCount

Default: 5 The maximum number of times Baileys will retry sending a failed message before giving up. Increase this only if you operate in unreliable network conditions.

Group performance

cachedGroupMetadata

A callback that returns cached GroupMetadata for a given JID, or undefined to trigger a live fetch. Every message sent to a group requires the group’s participant list to build Signal sender-key sessions. Without a cache, this triggers a network request for every message.
Set useClones: false on NodeCache when storing group metadata. Cloning large objects on every get adds measurable overhead in high-traffic bots.

Filtering events

shouldIgnoreJid

A predicate that receives a JID string and returns true to suppress all events and message decryption for that JID. Use this to skip broadcast lists, newsletters, or specific contacts you do not care about.

Timeouts and keep-alive


generateHighQualityLinkPreview

Default: false When true, Baileys uploads the link preview thumbnail to WhatsApp’s media servers so recipients see a high-resolution image. This requires link-preview-js to be installed.

Production-ready example

Here is a complete socket config that covers the most important options for a production bot: