npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fiwa

v2.0.0

Published

A lightweight WhatsApp bot with built-in MongoDB integration.

Readme

fiwa

A simple WhatsApp bot built on top of Baileys.

Features

  • Event-driven architecture for handling WhatsApp events like ready, message, qr, and more.
  • Send and receive messages with ease.
  • Group management: join, leave, and fetch group metadata.
  • Automatic reconnection with retry logic.
  • Customizable options for session management, logging, and device configuration.

Installation

You can install fiwa using your preferred package manager, but I recommend using Bun:

bun i fiwa

Usage

Here is a basic example of how to use the library:

import { FiWhatsAppClient } from "fiwa";

const client = new FiWhatsAppClient({
  phoneNumber: "1234567890", // Optional: for pairing code
  maxRetries: 5, // Optional: retry attempts for reconnection
});

client.on("qr", (qr) => {
  console.log("Scan this QR code:", qr);
});

client.on("ready", () => {
  console.log("Client is ready");
});

client.on("message", (message) => {
  const jid = message.key.remoteJid;
  client.sendText(jid!, "Hello world!");
});

client.start();

MongoDB Integration

fiwa uses the file system by default to store authentication state. However, fiwa now supports using MongoDB to store authentication state. This is useful for scenarios where you want to persist session data in a NoSQL database instead of the file system.

Configuration

To use MongoDB for session state, provide the mongodb option when creating the FiWhatsAppClient instance:

const client = new FiWhatsAppClient({
  mongodb: {
    url: "<your-mongodb-url>",
    databaseName: "<your-database-name>", // Optional, defaults to "fiwa"
    collectionName: "<your-collection-name>", // Optional, defaults to "fiwa_auth_state"
  },
});

Example

import { FiWhatsAppClient } from "fiwa";

const client = new FiWhatsAppClient({
  mongodb: {
    url: "mongodb+srv://...",
  },
});

client.on("ready", () => {
  console.log("Client is ready");
});

client.start();

When using MongoDB, the library will automatically handle storing and retrieving authentication credentials and keys from the specified collection.

API Reference

FiWhatsAppClient

Constructor

new FiWhatsAppClient(options?: FiWhatsAppOptions);
  • options (optional):
    • logPath (string): Path to the log file.
    • sessionDir (string): Directory for session data.
    • maxRetries (number): Maximum retry attempts for reconnection.
    • browser (string): Browser type (e.g., macOS, Windows).
    • device (string): Device name.
    • phoneNumber (string): Phone number for pairing.

Methods

  • start(): Promise<void>: Starts the WhatsApp client.
  • disconnect(): Promise<void>: Disconnects the client.
  • sendText(to: string, text: string): Promise<void>: Sends a text message.
  • getGroupMetadata(groupId: string): Promise<any>: Fetches metadata for a group.
  • joinGroup(inviteCode: string): Promise<void>: Joins a group using an invite code.
  • leaveGroup(groupId: string): Promise<void>: Leaves a group.

Events

  • ready: Emitted when the client is ready.
  • message: Emitted when a new message is received.
  • qr: Emitted when a QR code is generated.
  • pairingCode: Emitted when a pairing code is generated.
  • reconnect: Emitted when the client reconnects.
  • logout: Emitted when the client logs out.
  • error: Emitted when an error occurs.

Contribution

See CONTRIBUTING.md for details on how to contribute to this project.

License

This project is licensed under the MIT License. See the LICENSE file for details.

This project was created using bun init in bun v1.2.9. Bun is a fast all-in-one JavaScript runtime.