Use this file to discover all available pages before exploring further.
WA-JS runs entirely inside the browser. The compiled bundle (dist/wppconnect-wa.js) must be added to the WhatsApp Web page before your code calls any WPP.* function. Once the script loads, the loader initializes automatically, discovers WhatsApp’s internal module system, and fires lifecycle events to tell you when the API is ready.
Inject the WA-JS bundle as early as possible — before the user interacts with the WhatsApp Web page. Injecting after WhatsApp has already booted can cause the Webpack loader to miss the chunk callback window, falling back to a polling strategy that may delay or fail initialization. With the Meta loader (WA >= 2.3000.0) this is less of a concern, but injecting early is still the safest approach.
After the script is added to the page, WA-JS moves through a fixed sequence of states. Each state has a corresponding flag and callback hook.
1
Injection
The loader captures WhatsApp’s module system (Meta or Webpack). WPP.loader.isInjected becomes true and the internal loader.injected event fires.
2
Ready
Core WhatsApp modules are resolvable. WPP.loader.isReady and the top-level WPP.isReady both become true. The loader.ready event fires, and WPP.loader.onReady(callback) callbacks run.
3
Full ready
All runtime chunks have loaded, including locale bundles. WPP.loader.isFullReady becomes true and WPP.loader.onFullReady(callback) callbacks run. Most features are already available at the ready step; full ready is only needed for less common modules.
Use the appropriate method depending on whether you are inside the page or orchestrating from outside.
// Poll the flag directlyif (window.WPP?.isReady) { // already ready}// Or register a callback — fires immediately if already readyWPP.loader.onReady(function () { console.log('WA-JS ready');});// Wait for all chunks tooWPP.loader.onFullReady(function () { console.log('WA-JS fully ready');});
Every entity in WhatsApp is identified by a WhatsApp ID (Wid). The format depends on the entity type:
Entity
Format
Example
Contact / individual
{phone}@c.us
15551234567@c.us
Group
{groupId}@g.us
120363000000000001@g.us
Newsletter (Channel)
{id}@newsletter
123456789@newsletter
Status broadcast
status@broadcast
status@broadcast
Always include the suffix when passing IDs to WA-JS functions:
// Send a message to a contactawait WPP.chat.sendTextMessage('15551234567@c.us', 'Hello!');// Send a message to a groupawait WPP.chat.sendTextMessage('120363000000000001@g.us', 'Hello group!');
Before sending messages or reading data, verify that the session is authenticated and the connection is in a usable state.
WPP.loader.onReady(async function () { // Check authentication const authenticated = WPP.conn.isAuthenticated(); console.log('Authenticated:', authenticated); // Get full connection state const streamData = WPP.conn.getStreamData(); // { mode: 'MAIN', info: 'NORMAL' } console.log('Stream mode:', streamData.mode); console.log('Stream info:', streamData.info);});
React to connection changes in real time:
WPP.on('conn.stream_mode_changed', function (mode) { if (mode === 'MAIN') { console.log('WhatsApp is connected and ready'); } else if (mode === 'QR') { console.log('Waiting for QR code scan'); } else if (mode === 'OFFLINE') { console.log('Connection lost'); }});
See the Events page for the full list of stream modes and connection events.