Library for interacting with the WhatsApp Web API through electron and puppeteer
npm install @enderdba/wwebjs-electron

> π§ This is a fork of wwebjs-electron adapted for deep integration inside Electron using puppeteer-core and BrowserView, without puppeteer-in-electron, it uses the exact same code for puppeteer-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
---
``bash`
npm install @enderdba/wwebjs-electron puppeteer-core
> Note: You must be using Electron β₯ v17 and puppeteer-core (not full puppeteer) There's no need for it since it uses internal Electron built-in Chromium.
---
`ts
// 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:
`ts`
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.BrowserView
- Improve support for in multi-session contexts.puppeteer-core` and Electron's remote-debugging port.
- Work reliably with
- 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.