
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
redis-baileys
Advanced tools
Save your Baileys session in Redis DB using this powerful and efficient package!
npm install redis-baileys
or
yarn add redis-baileys
import { useRedisAuthState } from 'redis-baileys';
import { Boom } from '@hapi/boom';
import makeWASocket, { DisconnectReason } from '@whiskeysockets/baileys';
async function connectToWhatsApp() {
const redisConfig = {
password: 'your_redis_password',
host: 'your_redis_host',
port: 6379,
};
const { state, saveCreds } = await useRedisAuthState(redisConfig, 'your_session_id');
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
});
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update;
if (connection === 'close') {
const shouldReconnect = (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut;
console.log('connection closed due to ', lastDisconnect?.error, ', reconnecting ', shouldReconnect);
if (shouldReconnect) {
connectToWhatsApp();
}
} else if (connection === 'open') {
console.log('opened connection');
}
});
sock.ev.on('creds.update', saveCreds);
}
connectToWhatsApp();
const { useRedisAuthState } = require('redis-baileys');
const { Boom } = require('@hapi/boom');
const makeWASocket = require('@whiskeysockets/baileys').default;
async function connectToWhatsApp() {
const redisConfig = {
password: 'your_redis_password',
host: 'your_redis_host',
port: 6379,
};
const { state, saveCreds } = await useRedisAuthState(redisConfig, 'your_session_id');
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
});
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update;
if (connection === 'close') {
const shouldReconnect = (lastDisconnect?.error instanceof Boom) && lastDisconnect.error.output.statusCode !== DisconnectReason.loggedOut;
console.log('connection closed due to ', lastDisconnect?.error, ', reconnecting ', shouldReconnect);
if (shouldReconnect) {
connectToWhatsApp();
}
} else if (connection === 'open') {
console.log('opened connection');
}
});
sock.ev.on('creds.update', saveCreds);
}
connectToWhatsApp();
useRedisAuthState(redisConfig, sessionId)
Creates and manages the authentication state using Redis.
redisConfig
: An object containing Redis connection details (password, host, port).sessionId
: A unique identifier for the session.Returns an object with:
state
: The current authentication state.saveCreds
: A function to save credentials.deleteSession
: A function to delete the current session.For more detailed documentation, please visit our Wiki.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Made with ❤️ by HacxK
FAQs
Save your baileys session in redisdb using this package
The npm package redis-baileys receives a total of 16 weekly downloads. As such, redis-baileys popularity was classified as not popular.
We found that redis-baileys demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.