Registry / database / wwebjs-mongo

wwebjs-mongo

JSON →
library1.1.0jsnpmunverified

MongoDB plugin for whatsapp-web.js to persist WhatsApp MultiDevice sessions. v1.1.0 is the current stable release. It uses Mongoose under the hood to store session data in MongoDB, enabling session recovery across app restarts. Key differentiator: it is the official MongoDB store for TheRemoteAuth strategy in whatsapp-web.js, replacing the default in-memory store. Simple to integrate with just a few lines of code.

npm install wwebjs-mongo
INSTALL
IMPORT
SIG · WWEBJS-MONGO
W
wwebjs-mongo
databasejavascriptv1.1.0
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.

MongoStore
import { MongoStore } from 'wwebjs-mongo'
const MongoStore = require('wwebjs-mongo')
ESM import as used in Node.js with 'type':'module' or .mjs files.
MongoStore
const { MongoStore } = require('wwebjs-mongo')
const MongoStore = require('wwebjs-mongo').MongoStore
CommonJS destructured require().
MongoStore
import { MongoStore } from 'wwebjs-mongo'
import MongoStore from 'wwebjs-mongo'
Default import not available; use named import.

Creates a WhatsApp client with MongoDB session persistence using RemoteAuth and MongoStore.

const { Client, RemoteAuth } = require('whatsapp-web.js'); const { MongoStore } = require('wwebjs-mongo'); const mongoose = require('mongoose'); mongoose.connect(process.env.MONGODB_URI ?? '').then(() => { const store = new MongoStore({ mongoose: mongoose }); const client = new Client({ authStrategy: new RemoteAuth({ store: store, backupSyncIntervalMs: 300000 }) }); client.on('ready', () => console.log('Client is ready!')); client.initialize(); }).catch(err => console.error(err));
Debug
Known issues
gotchaMongoose must be passed to MongoStore explicitly; the plugin does not auto-initialize its own connection.
fix
Pass the mongoose instance: new MongoStore({ mongoose: mongoose })
affects: >=1.0.0
gotchaMongoStore relies on whatsapp-web.js's RemoteAuth strategy and will not work with other auth strategies.
fix
Ensure you are using RemoteAuth as shown in the quickstart.
affects: >=1.0.0
gotchaThe delete method expects an object with a session property; using a string will not work.
fix
Use await store.delete({ session: 'yourSessionName' })
affects: >=1.0.0
gotchaThe MongoStore does not handle disconnection or reconnection of Mongoose; it assumes the connection is alive when methods are called.
fix
Implement your own reconnection logic outside this package.
affects: >=1.0.0
gotchaThe plugin uses Mongoose schemas; ensure the MongoDB connection is established before creating MongoStore.
fix
Call mongoose.connect() before new MongoStore(...).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: MongoStore is not a constructor
Importing wrong default/namespace instead of named export.
fix
Use const { MongoStore } = require('wwebjs-mongo') or import { MongoStore } from 'wwebjs-mongo'.
MongooseError: The `mongoose` option is required
MongoStore instantiated without passing mongoose instance.
fix
Pass the mongoose instance: new MongoStore({ mongoose: require('mongoose') })
MongoServerError: Authentication failed
MongoDB connection string missing credentials or using wrong database.
fix
Check MONGODB_URI and ensure user has read/write permissions on the target database.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
mongooserequiredPeer dependency for MongoDB connection and operations
whatsapp-web.jsrequiredProvides the RemoteAuth strategy that this plugin integrates with
Agent activity
36 hits · last 30 days
node
32
OpenAI (training)
1
Resources
wwebjs-mongo — npm install wwebjs-mongo · libregistry