An enhanced and stabilized fork of the WhatsApp Web API client that connects through the WhatsApp Web browser app.
- Fixed issue with message events not firing after browser restart
- Added
reinitializeCryptoStoremethod for proper session handling - Improved ciphertext message handling
- Reliable group chat detection using server type
- Consistent behavior across chat and contact models
- Fixed issues with group message handling
npm install @ismailkhcm/whatsapp-web.jsconst { Client, LocalAuth } = require('@ismailkhcm/whatsapp-web.js');
const client = new Client({
authStrategy: new LocalAuth()
});
client.on('qr', (qr) => {
console.log('QR RECEIVED', qr);
});
client.on('ready', () => {
console.log('Client is ready!');
});
// Handle session restoration
client.on('authenticated', async () => {
console.log('Authenticated');
await client.reinitializeCryptoStore(); // Call this after session restoration
});
client.on('message', msg => {
if (msg.body === '!ping') {
msg.reply('pong');
}
});
client.initialize();To ensure message events work correctly after session restoration:
// After initializing with a saved session
await client.initialize();
await client.reinitializeCryptoStore();Group chats are now reliably detected:
client.on('message', async msg => {
const chat = await msg.getChat();
if (chat.isGroup) {
console.log('Message is from group:', chat.name);
}
});- ✅ Multi-device support
- ✅ Message sending and receiving
- ✅ Message history
- ✅ Group chat management
- ✅ Media sending and downloading
- ✅ Message reactions
- ✅ Contact management
- ✅ Business account features
- ✅ And more...
Full documentation is available at docs/README.md.
# Run all tests
npm test
# Run specific test
npm run test:specific tests/message_events.jsSee IMPROVEMENTS.md for planned improvements and how to contribute.
- Create an issue for bug reports
- Join our community for discussions
- Commercial support available
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This project is a fork of whatsapp-web.js with additional improvements and stability fixes.