🧠 This is a fork of
wwebjs-electron
adapted for deep integration inside Electron usingpuppeteer-core
andBrowserView
, withoutpuppeteer-in-electron
, it uses the exact same code forpuppeteer-in-electron
only with new dependencies.
- 🧩 100% compatible with whatsapp-web.js
- 🧠 No need for external Puppeteer installation: works with Electron’s built-in Chromium
- 🔐 Session management via persistent partition (
BrowserView
) - 📦 Minimal dependencies, clean API
npm install @enderdba/wwebjs-electron puppeteer-core
Note: You must be using Electron ≥ v17 and
puppeteer-core
(not fullpuppeteer
) There's no need for it since it uses internal Electron built-in Chromium.
// main.ts
import { app, BrowserWindow, BrowserView } from 'electron';
import puppeteer from 'puppeteer-core';
import { Client, ElectronPuppeteer } from '@enderdba/wwebjs-electron';
let win: BrowserWindow;
let client: Client;
await ElectronPuppeteer.initialize(app); // ⬅️ MUST be before app.isReady()
app.whenReady().then(async () => {
const browser = await ElectronPuppeteer.connect(app, puppeteer);
win = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
contextIsolation: true,
partition: 'persist:whatsapp_xxxx',
},
});
const view = new BrowserView({
webPreferences: {
contextIsolation: true,
partition: 'persist:whatsapp_xxxx',
},
});
win.setBrowserView(view);
view.setBounds({ x: 0, y: 0, width: 1200, height: 800 });
await view.webContents.loadURL('https://web.whatsapp.com');
client = new Client(browser, view, {
webVersionCache: { type: 'none' }
});
client.on('ready', () => console.log('✅ Client is ready!'));
client.on('message', msg => {
if (msg.body === '!ping') msg.reply('pong');
});
await client.initialize();
});
You do not need to use authentication strategies. Electron handles session storage via partition
:
partition: 'persist:whatsapp-session_123'
Just assign a different partition per session and you're done. You can save partitions in a JSON, SQLite, anywhere, just make sure you persist it somewhere.
- You can extract
ClientInfo
,Chat
,Contact
,Message
and other classes directly from@enderdba/wwebjs-electron
, just like in WWEBJS!. - All whatsapp-web.js features are supported, including stickers, polls, buttons, and media.
This is a custom fork of wwebjs-electron
, with some tweaks for:
- Eliminate
puppeteer-in-electron
dependency since it's integrated now. - Improve support for
BrowserView
in multi-session contexts. - Work reliably with
puppeteer-core
and Electron's remote-debugging port. - Integrate better with TypeScript.
- Doesn't close out the entire browser, just the page that renders Whatsapp. Maintained by @enderdba
Apache-2.0. See LICENSE
WhatsApp is a trademark of WhatsApp Inc., and this project is not affiliated with them in any way.