Skip to content

A remote authentication plugin for whatsapp-web.js, using Firebase Storage to securely store WhatsApp multi-device session data.

License

Notifications You must be signed in to change notification settings

vedantmgoyal9/wwebjs-firebase-storage

Repository files navigation

wwebjs-firebase-storage

NPM Version NPM Downloads GitHub License

A remote authentication plugin for whatsapp-web.js, using Firebase Storage to securely store WhatsApp multi-device session data.

Quick Links

Installation

npm install wwebjs-firebase-storage

Example usage

import { Client, RemoteAuth } from 'whatsapp-web.js';
import { initializeApp, getStorage, FirebaseStorageStore } from 'wwebjs-firebase-storage';
import qrcode_terminal from 'qrcode-terminal';
const app = initializeApp({
    apiKey: <firebase-api-key>,
    projectId: <firebase-project-id>,
    storageBucket: <firebase-storage-bucket>,
});
const client = new Client({
    authStrategy: new RemoteAuth({
        store: new FirebaseStorageStore({
            firebaseStorage: getStorage(app),
            sessionPath: 'sessions-whatsapp-web.js', // save in a sub-directory
        }),
        backupSyncIntervalMs: 600000, // 10 minutes
    }),
    ... // other options
});
client.on('qr', qr => {
    qrcode_terminal.generate(qr, {small: true});
});
client.on('remote_session_saved', () => console.log('Remote session saved!'));
client.on('authenticated', () => console.log('Authenticated!'));
client.on('auth_failure', () => console.log('Authentication failed!'));
client.on('ready', () => console.log('Client is ready!'));
client.initialize();