wwjs-stable-client
v2.0.9
Published
whatsapp-web.js stable client version
Downloads
437
Maintainers
Readme
wwjs-stable-client
A stable and consistent wrapper for WhatsApp Web JS to manage versions across multiple projects.
Motivation
Managing WhatsApp Web JS versions across multiple projects can be challenging. This package provides a consistent, stable client implementation to simplify version management and reduce configuration overhead.
Installation
npm install wwjs-stable-client
Usage
import {
StableWhatsappClient,
STABLE_WEB_VERSION,
STABLE_WWJS_VERSION,
} from "wwjs-stable-client";
// Create a client instance
const stable = new StableWhatsappClient({
// Optional: custom QR code handler
onQR: (qr) => {
console.log("Scan this QR code to authenticate");
},
});
// Listen for client ready event
stable.onStableClientReady(() => {
console.log("WhatsApp client is ready!");
// Access the underlying whatsapp-web.js client
stable.client.on("message", (msg) => {
console.log("Received message:", msg.body);
});
});
// Initialize the client
stable.initialize();
Important Note
Wait at least 2 minutes after the first authentication in order to save the LocalAuth persistently.
Configuration
The client uses sensible defaults:
- Local authentication strategy
- Cached web version
- Puppeteer configuration for compatibility
Customizing Authentication
import { StableWhatsappClient } from "wwjs-stable-client";
import { RemoteAuth } from "whatsapp-web.js";
// Use a custom authentication strategy
const stableClient = new StableWhatsappClient({
authStrategy: new RemoteAuth(),
onQR: (qr) => {
// Custom QR handling
},
});
API
Constructor Options
authStrategy
: Custom authentication strategy (defaults toLocalAuth
)onQR
: Optional callback for QR code handling
Methods
onStableClientReady(callback)
: Register a callback for when the client is readyclient
: Access to the underlying whatsapp-web.jsClient
instance
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.