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 that wraps WhatsApp Web’s internal modules and exposes them as the global WPP object. By the end of this guide you will have WA-JS running in a real WhatsApp Web session and will have sent your first message programmatically.
Prerequisites
Before you begin, make sure you have the following:- Node.js 18 or later — required if you are automating via Playwright or a similar framework
- A WhatsApp account — you need an active account to authenticate with WhatsApp Web
- A Chromium-based browser — WA-JS injects into the WhatsApp Web page; Chrome, Edge, or Playwright’s bundled Chromium all work
Steps
Install the package
Add If you are using a userscript manager such as TamperMonkey or GreaseMonkey instead, skip this step and use the CDN script tag shown in the next step.
@wppconnect/wa-js to your project using your preferred package manager.Inject WA-JS into WhatsApp Web
WA-JS must run inside the WhatsApp Web page context. Choose the approach that matches your setup.CDN / userscript — add a Playwright — inject the built bundle with
@require directive pointing to the nightly release:tampermonkey-header.js
addScriptTag after navigating to WhatsApp Web:playwright.ts
Wait for WA-JS to be ready
WA-JS initialises asynchronously while WhatsApp Web loads its own modules. Always wait for the ready signal before calling any In Playwright, poll the
WPP function.In a userscript or inline browser script, use WPP.loader.onReady():browser-context.js
WPP.isReady flag from the Node.js side:playwright.ts
Send your first message
Once WA-JS is ready, use From Playwright, evaluate the call inside the page context:
WPP.chat.sendTextMessage() to send a text message. Pass the recipient’s WhatsApp ID and the message text.browser-context.js
playwright.ts
WhatsApp IDs follow a specific format. Use
number@c.us for individual contacts (e.g. 5511999999999@c.us) and groupid@g.us for groups. The number must include the full country code with no +, spaces, or dashes.Complete working example
The snippet below brings all four steps together in a single Playwright script. Scan the QR code when the browser opens, then watch your message arrive.complete-example.ts