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();
Errors
Common errors & fixes
Cannot find module 'wwebjs-mysql'
Package not installed
fixRun: npm install wwebjs-mysql
MysqlStore is not a constructor
Incorrect import (default import instead of named import)
fixUse: const { MysqlStore } = require('wwebjs-mysql') ERR_REQUIRE_ESM: require() of ES Module not supported
Attempting to use CommonJS require on an ES module
fixEnsure your project uses CommonJS (e.g., "type": "commonjs" in package.json or .cjs extension)
Audit
Dependencies
whatsapp-web.jsrequiredpeer dependency — must be installed separately
mysql2requiredused for creating connection pool; alternative MySQL drivers may not be supported