{"id":44117,"library":"wa-multi-mongodb","title":"WA Multi MongoDB","description":"A multi-session WhatsApp library with MongoDB session storage, built on Baileys. v3.11.1 (Jul 2024) uses MongoDB for scalable auth/session persistence, auto-loads sessions at startup, supports QR scan only once per device, and includes auto-reconnect, group chat detection, message deletion, custom browser config, proxy support, and media download. Differentiates from file-based alternatives by using MongoDB for better scalability and session management. TypeScript types included.","status":"active","version":"3.11.1","language":"javascript","source_language":"en","source_url":"https://github.com/wahdalo/wa-multi-mongodb","tags":["javascript","typescript"],"install":[{"cmd":"npm install wa-multi-mongodb","lang":"bash","label":"npm"},{"cmd":"yarn add wa-multi-mongodb","lang":"bash","label":"yarn"},{"cmd":"pnpm add wa-multi-mongodb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core WhatsApp Web protocol implementation","package":"@whiskeysockets/baileys","optional":false},{"reason":"MongoDB driver for session storage","package":"mongodb","optional":false}],"imports":[{"note":"ESM recommended; CJS require also works but may lack TypeScript inference.","wrong":"const whatsapp = require('wa-multi-mongodb')","symbol":"* as whatsapp","correct":"import * as whatsapp from 'wa-multi-mongodb'"},{"note":"This is a named export, not default.","wrong":"import startSession from 'wa-multi-mongodb'","symbol":"startSession","correct":"import { startSession } from 'wa-multi-mongodb'"},{"note":"For TypeScript type imports, use 'import type' to avoid runtime value.","wrong":"import { WhatsappSession } from 'wa-multi-mongodb'","symbol":"WhatsappSession","correct":"import type { WhatsappSession } from 'wa-multi-mongodb'"}],"quickstart":{"code":"import * as whatsapp from 'wa-multi-mongodb';\nrequire('dotenv').config();\n\nconst MONGODB_URI = process.env.MONGODB_URI ?? '';\nif (!MONGODB_URI) {\n  console.error('Error: MONGODB_URI not found in environment variables');\n  process.exit(1);\n}\n\nasync function main() {\n  await whatsapp.setMongoURI(MONGODB_URI);\n  // Optionally customize database/collection:\n  // whatsapp.setMongoDBNames('custom_db', 'custom_collection');\n\n  const session = await whatsapp.startSession('mysession', {\n    printQR: true,\n    onQRUpdated: (qr) => console.log('Scan QR:', qr.substring(0, 50) + '...'),\n    onConnected: () => console.log('Connected!'),\n    sessionId: 'default',\n  });\n\n  // Send a message\n  await session.sendMessage('xxxxxxxxxx@s.whatsapp.net', {\n    text: 'Hello from wa-multi-mongodb!',\n  });\n\n  console.log('Message sent!');\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Initializes MongoDB connection, starts a WhatsApp session with QR code, and sends a text message."},"warnings":[{"fix":"Replace getConnectionState() with event listeners (session.events.on('connection.update', ...)).","message":"getConnectionState() is no longer recommended; use session.events instead.","severity":"deprecated","affected_versions":">=3.10.0"},{"fix":"Wrap startSession() in try/catch to handle connection errors properly.","message":"startSession() no longer returns a Promise<undefined> on failure; throws an error instead.","severity":"breaking","affected_versions":">=3.11.0"},{"fix":"Always call await whatsapp.setMongoURI(uri) before any session operations.","message":"MongoDB URI must be set before starting sessions or an error is thrown.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use the default collection names unless you have a specific reason; avoid relying on custom names.","message":"setMongoDBNames() is experimental and may be removed in future versions.","severity":"deprecated","affected_versions":">=3.10.0"},{"fix":"Test proxy thoroughly; prefer HTTP/HTTPS proxies over SOCKS. Set proxy via startSession options.","message":"Proxy support requires additional configuration; not all proxies work with Baileys WebSocket.","severity":"gotcha","affected_versions":">=3.10.8"}],"env_vars":null,"search_vec":"'2024':19 'altern':62 'auth/session':24 'auto':27,42 'auto-load':26 'auto-reconnect':41 'bailey':16 'base':61 'better':67 'browser':50 'built':14 'chat':45 'config':51 'custom':49 'delet':48 'detect':46 'devic':38 'differenti':57 'download':56 'file':60 'file-bas':59 'group':44 'includ':40,74 'javascript':75 'jul':18 'librari':9 'load':28 'manag':71 'media':55 'messag':47 'mongodb':3,11,21,65 'multi':2,6 'multi-sess':5 'per':37 'persist':25 'proxi':52 'qr':33 'reconnect':43 'scalabl':23,68 'scan':34 'session':7,12,29,70 'startup':31 'storag':13 'support':32,53 'type':73 'typescript':72,76 'use':20,64 'v3.11.1':17 'wa':1 'whatsapp':8","created_at":"2026-06-05T17:03:03.493602+00:00","updated_at":"2026-06-05T17:03:03.493602+00:00","problems":[{"fix":"Check MongoDB connection string, ensure MongoDB is running, and network allows access.","cause":"MongoDB server is not running or URI is incorrect.","error":"MongoServerSelectionError: connect ECONNREFUSED ..."},{"fix":"Use: import * as whatsapp from 'wa-multi-mongodb' or import { startSession } from 'wa-multi-mongodb'","cause":"Incorrect import style; used default import instead of named import.","error":"TypeError: whatsapp.startSession is not a function"},{"fix":"Call await whatsapp.setMongoURI(process.env.MONGODB_URI) before any session operation.","cause":"Attempted to start session before setting MongoDB URI.","error":"Error: MongoDB URI not set. Call setMongoURI() first."},{"fix":"Ensure both packages are compatible; stick to versions specified in peerDependencies.","cause":"Incorrect Baileys version or mismatch between wa-multi-mongodb and Baileys.","error":"ERR_UNKNOWN_ENCODING: Unsupported encoding \"utf8\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/wahdalo/wa-multi-mongodb#readme","github":"https://github.com/wahdalo/wa-multi-mongodb","docs":null,"changelog":null,"pypi":null,"npm":"wa-multi-mongodb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}