Skip to main content

Overview

The makeWASocket function accepts a comprehensive configuration object that controls every aspect of your WhatsApp connection. This guide covers all available options from the SocketConfig type.
All configuration options are optional and have sensible defaults from DEFAULT_CONNECTION_CONFIG.

Basic Configuration

Connection Options

waWebSocketUrl

The WebSocket URL to connect to WhatsApp servers.
Default: 'wss://web.whatsapp.com/ws/chat'

connectTimeoutMs

Timeout for establishing the WebSocket connection.
Default: 20000 (20 seconds)
Type: number (milliseconds)
If the connection doesn’t establish within this timeout, it will fail and you’ll need to retry.

keepAliveIntervalMs

Interval for ping-pong messages to keep the WebSocket alive.
Default: 30000 (30 seconds)
Type: number (milliseconds)

defaultQueryTimeoutMs

Default timeout for query requests to WhatsApp.
Default: 60000 (60 seconds)
Type: number | undefined
Set to undefined for no timeout, but this is not recommended.

Authentication Options

auth

Required. Authentication state containing credentials and keys.
Type: AuthenticationState

printQRInTerminal

Automatically print QR code to terminal (deprecated in favor of manual handling).
Default: Not set
Type: boolean
This feature is deprecated. Handle QR codes via the connection.update event instead.

qrTimeout

Time to wait for QR code generation.
Default: Not set
Type: number (milliseconds)

Browser Configuration

browser

Browser identity shown in WhatsApp’s “Linked Devices”.
Default: Browsers.macOS('Chrome')
Type: [platform: string, appName: string, version: string]
Available presets:
  • Browsers.ubuntu(appName) - Ubuntu 22.04.4
  • Browsers.macOS(appName) - Mac OS 14.4.1
  • Browsers.windows(appName) - Windows 10.0.22631
  • Browsers.baileys(appName) - Baileys 6.5.0
  • Browsers.appropriate(appName) - Auto-detect from OS

version

WhatsApp Web version to use.
Default: [2, 3000, 1033846690]
Type: [major: number, minor: number, patch: number]

Message & Media Options

getMessage

Fetch messages from your store for retry handling and poll decryption.
Default: async () => undefined
Type: (key: WAMessageKey) => Promise<proto.IMessage | undefined>
Not implementing getMessage will prevent message retries and poll vote decryption.

customUploadHosts

Custom media upload servers.
Default: []
Type: MediaConnInfo['hosts']

generateHighQualityLinkPreview

Generate high-quality link previews by uploading thumbnails.
Default: false
Type: boolean

linkPreviewImageThumbnailWidth

Width for link preview thumbnails.
Default: 192
Type: number (pixels)

History & Sync Options

syncFullHistory

Request full chat history from WhatsApp.
Default: true
Type: boolean
Desktop browsers receive more history than mobile browsers when this is enabled.

shouldSyncHistoryMessage

Control which history messages to process.
Default: Skips FULL sync
Type: (msg: proto.Message.IHistorySyncNotification) => boolean

fireInitQueries

Automatically fire initialization queries on connection.
Default: true
Type: boolean

Behavior Options

markOnlineOnConnect

Automatically mark as online when socket connects.
Default: true
Type: boolean
Set to false if you want to receive push notifications on your phone.

emitOwnEvents

Emit events for actions performed by this socket.
Default: true
Type: boolean

shouldIgnoreJid

Ignore events from specific JIDs.
Default: () => false
Type: (jid: string) => boolean | undefined

patchMessageBeforeSending

Modify messages before sending.
Default: msg => msg (no modification)
Type: Function that returns patched message(s)

Retry & Cache Options

retryRequestDelayMs

Delay between retry attempts for failed messages.
Default: 250 (milliseconds)
Type: number

maxMsgRetryCount

Maximum number of retry attempts.
Default: 5
Type: number

msgRetryCounterCache

Cache for tracking message retry counts.
Default: Not set
Type: CacheStore
Keep this cache outside the socket to prevent retry loops across reconnections.

mediaCache

Cache for media uploads to avoid re-uploading.
Default: Not set
Type: CacheStore

userDevicesCache

Cache for user device lists.
Default: Not set
Type: PossiblyExtendedCacheStore

callOfferCache

Cache for call offers.
Default: Not set
Type: CacheStore

placeholderResendCache

Cache for tracking placeholder resend requests.
Default: Not set
Type: CacheStore

Performance Options

cachedGroupMetadata

Cache group metadata to reduce API calls.
Default: async () => undefined
Type: (jid: string) => Promise<GroupMetadata | undefined>
Highly recommended for bots that interact with groups to reduce API load.

enableAutoSessionRecreation

Automatically recreate sessions for failed messages.
Default: true
Type: boolean

enableRecentMessageCache

Cache recent messages for retry handling.
Default: true
Type: boolean

Network Options

agent

Proxy agent for WebSocket connection.
Default: Not set
Type: Agent

fetchAgent

Agent for HTTP fetch requests (media upload/download).
Default: Not set
Type: Agent

options

Options for HTTP fetch requests.
Default: {}
Type: RequestInit

Advanced Options

countryCode

Alphanumeric country code for the phone number.
Default: 'US'
Type: string

logger

Logger instance for debugging.
Default: Pino logger with level ‘info’
Type: ILogger

transactionOpts

Transaction options for Signal key store operations.
Default: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 }
Type: TransactionCapabilityOptions

appStateMacVerification

Verify app state MACs for security.
Default: { patch: false, snapshot: false }
Type: { patch: boolean; snapshot: boolean }

makeSignalRepository

Custom Signal protocol repository factory.
Default: makeLibSignalRepository
Type: Function

Complete Configuration Example

Configuration Best Practices

1

Implement getMessage

Always implement getMessage for message retry and poll decryption support.
2

Use Latest Version

Fetch and use the latest WhatsApp Web version with fetchLatestBaileysVersion().
3

Cache Group Metadata

Implement cachedGroupMetadata if your bot works with groups to reduce API calls.
4

External Retry Cache

Keep msgRetryCounterCache outside the socket to prevent retry loops on reconnection.
5

Adjust for Environment

Set markOnlineOnConnect: false if users should receive phone notifications.
6

Enable High Quality Previews

Set generateHighQualityLinkPreview: true for better link preview images.

Next Steps

Session Management

Implement getMessage and auth state

Handling Events

Use socket to handle events

Sending Messages

Send messages with your configured socket