@enderdba/wwebjs-electron
TypeScript icon, indicating that this package has built-in type declarations

1.28.4 • Public • Published

@enderdba/wwebjs-electron

npm GitHub

🧠 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.

✅ Features

  • 🧩 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

🚀 Installation

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.


🧪 Example (Electron main process)

// 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();
});

📌 Session Management

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.


💡 Advanced

  • 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.

📦 About this fork

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

📄 License

Apache-2.0. See LICENSE

WhatsApp is a trademark of WhatsApp Inc., and this project is not affiliated with them in any way.

Package Sidebar

Install

npm i @enderdba/wwebjs-electron

Weekly Downloads

12

Version

1.28.4

License

Apache-2.0

Unpacked Size

396 kB

Total Files

53

Last publish

Collaborators

  • enderdba