Registry / storage / wwebjs-mysql

wwebjs-mysql

JSON →
library0.1.4jsnpmunverified

MySQL plugin for whatsapp-web.js that enables MultiDevice session persistence in MySQL databases. Current version 0.1.4, no regular release cadence. Differentiates from other wwebjs stores by targeting MySQL users; provides a MySQLStore class compatible with RemoteAuth strategy. Requires whatsapp-web.js, mysql2, and a MySQL instance.

npm install wwebjs-mysql
INSTALL
IMPORT
SIG · WWEBJS-MYSQL
W
wwebjs-mysql
storagejavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MysqlStore
const { MysqlStore } = require('wwebjs-mysql')
const MysqlStore = require('wwebjs-mysql')
Import is via named export from CommonJS module.
MysqlStore
import { MysqlStore } from 'wwebjs-mysql'
import MysqlStore from 'wwebjs-mysql'
ESM import uses named import, not default. Package does not ship ESM.
MysqlStore
const { MysqlStore } = require('wwebjs-mysql')
const { MysqlStore } = require('wwebjs-mysql').default
No default export exists.

Set up a WhatsApp client with MySQL session store using RemoteAuth.

const { Client, RemoteAuth } = require('whatsapp-web.js'); const { MysqlStore } = require('wwebjs-mysql'); const mysql = require('mysql2/promise'); const pool = mysql.createPool({ host: process.env.DB_MYSQL_HOST ?? 'localhost', user: process.env.DB_MYSQL_USER ?? 'root', password: process.env.DB_MYSQL_PASSWORD ?? '', database: process.env.DB_MYSQL_DATABASE ?? 'whatsapp', waitForConnections: true, connectionLimit: 10, queueLimit: 0 }); const tableInfo = { table: 'wsp_sessions', session_column: 'session_name', data_column: 'data', updated_at_column: 'updated_at' }; const store = new MysqlStore({ pool: pool, tableInfo: tableInfo }); const client = new Client({ authStrategy: new RemoteAuth({ store: store, backupSyncIntervalMs: 300000, session: 'your-session-name' }) }); client.initialize();
Debug
Known issues
gotchaRequires a pre-existing MySQL table with specific columns as defined in tableInfo.
fix
Create table using the SQL statement provided in README before initializing the store.
affects: >=0.1.0
gotchaThe package is a CommonJS module; ESM import requires using named import syntax.
fix
Use import { MysqlStore } from 'wwebjs-mysql'.
affects: >=0.1.0
breakingDoes not support other MySQL drivers (e.g., mysql). Only mysql2 is compatible.
fix
Install and use mysql2 package for connection pooling.
affects: >=0.1.0
gotchaRemoteAuth session must be unique per WhatsApp instance; duplicate sessions cause data conflicts.
fix
Ensure each client uses a distinct session name.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'wwebjs-mysql'
Package not installed
fix
Run: npm install wwebjs-mysql
MysqlStore is not a constructor
Incorrect import (default import instead of named import)
fix
Use: const { MysqlStore } = require('wwebjs-mysql')
ERR_REQUIRE_ESM: require() of ES Module not supported
Attempting to use CommonJS require on an ES module
fix
Ensure your project uses CommonJS (e.g., "type": "commonjs" in package.json or .cjs extension)
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
whatsapp-web.jsrequiredpeer dependency — must be installed separately
mysql2requiredused for creating connection pool; alternative MySQL drivers may not be supported
Agent activity
42 hits · last 30 days
node
38
Amazon
1
Resources
wwebjs-mysql — npm install wwebjs-mysql · libregistry