WA-JS (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/wppconnect-team/wa-js/llms.txt
Use this file to discover all available pages before exploring further.
@wppconnect/wa-js) is a browser injection library. After being injected into the WhatsApp Web page at runtime, it discovers WhatsApp’s internal module system, extracts the functions and data models it needs, and re-exports them through a single stable public API: the global window.WPP object. None of the internals are exposed directly — everything passes through a feature layer that WA-JS controls.
The WPP global object
When the bundle is injected and the loader finishes,window.WPP becomes available in the browser context. Its top-level namespaces map directly to src/index.ts:
| Namespace | Purpose |
|---|---|
WPP.loader | Loader state (isReady, isFullReady) and lifecycle hooks (onReady, onFullReady) |
WPP.whatsapp | Low-level bindings to WhatsApp internals (models, collections, stores, functions) |
WPP.chat | Chat functions and events (sendTextMessage, get, deleteMessage, …) |
WPP.conn | Connection management (isAuthenticated, getStreamData, logout, refreshQR, …) |
WPP.contact | Contact lookup and management |
WPP.group | Group creation, participant management, invite codes |
WPP.blocklist | Block and unblock contacts |
WPP.community | Community and subgroup management |
WPP.newsletter | WhatsApp Channels (newsletters) |
WPP.catalog / WPP.cart / WPP.order | Business catalog and ordering |
WPP.status | Status (story) posting and reading |
WPP.labels / WPP.lists | Chat organization features |
WPP.profile / WPP.privacy | Profile and privacy settings |
WPP.ev | Global event emitter (also re-exported as top-level WPP.on, WPP.off, etc.) |
WPP.on, WPP.off, WPP.once, WPP.onAny, WPP.waitFor) are re-exported at the top level directly from the event emitter for convenience.
The loader system
The most critical piece of WA-JS issrc/loader/. Because WhatsApp Web’s module bundler has changed over time, the loader detects which module system is active and adapts accordingly.
Meta loader
Used for WhatsApp Web >= 2.3000.0. Calls
global.require() wrapped with ErrorGuard.skipGuardGlobal() to bypass WhatsApp’s internal error guards. Installs setter traps on global.__d and global.require to start the moment those globals are assigned.Webpack loader
Used for legacy versions. Intercepts webpack chunk callbacks at startup by pushing into
webpackChunkwhatsapp_web_client before WhatsApp’s own bundles run, obtaining a reference to __webpack_require__ and all loaded modules.moduleRequire interface to the rest of WA-JS, so all src/whatsapp/ imports resolve transparently through whichever loader is active. The loader progresses through three lifecycle states:
| State | Flag | Meaning |
|---|---|---|
| Injected | WPP.loader.isInjected | Loader has captured the module system |
| Ready | WPP.loader.isReady | Core WhatsApp modules are resolvable |
| Full ready | WPP.loader.isFullReady | All runtime chunks have loaded |
Module layout
Feature modules follow a consistent internal structure. Takingsrc/chat/ as an example:
src/<feature>/ wraps the low-level bindings in src/whatsapp/. The whatsapp directory is organized by type:
...Model— a data model class (e.g.ChatModel,MsgModel)...Collection— a collection of models (e.g.ChatCollection,MsgCollection)...Store— the global singleton instance of a collection (e.g.ChatStore,MsgStore)
Architectural layers
The following table shows how data flows from WhatsApp Web’s internals to your code:| Layer | Location | Role |
|---|---|---|
| WhatsApp Web internals | Browser JS bundle | Models, collections, stores, raw functions |
| WA-JS loader | src/loader/ | Captures the module system; resolves internal modules |
src/whatsapp/ bindings | src/whatsapp/ | Typed wrappers around the raw internal modules |
| Feature modules | src/<feature>/ | Public, versioned API: functions, patches, events |
window.WPP | dist/wppconnect-wa.js | Single UMD global your code calls |
Build output
Webpack (configured inwebpack.config.js) bundles everything from src/index.ts into a single UMD file:
type: 'global' with name: 'WPP', so after injection the object is available on window.WPP without any import statement. The src/tools/ directory contains development utilities that are excluded from the bundle.
src/whatsapp/ bindings are internal implementation details, not public API. They expose raw WhatsApp internals and may break whenever WhatsApp ships an update. Always use the feature modules (WPP.chat, WPP.conn, WPP.contact, etc.) in your own code.