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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bitxenia/astrachat

v0.0.30

Published

Decentralized p2p real-time chat on IPFS

Readme

Astrachat

Astrachat is an implementation of a real-time messaging service that makes use of IPFS and OrbitDB to achieve a community driven, decentralized way of sending messages between users. Making use of this module, users can create their own group chats and chat spaces.

Given that this node is completely community driven and decentralized, users support their own chat spaces by becoming a collaborative node. This way, the community can help make their chats persistent and fully reachable.

Note that this project is meant as a library to be used by any frontend that supports it. It's meant to run on both Node.js and a browser environment. As an example, bitxenia's astrawiki-web browser frontend includes chat support within articles, using this library.

Install

npm install @bitxenia/astrachat

Features

  • Chat with other peers without relying on a centralized organization.
  • Make your own community chat space to group all the relevant chats to your community, similar to a Discord server.
  • Support the community of your choosing by becoming a collaborator. See Collaborating for more.

Usage

To create a node instance, use the createAstrachat function:

import { createAstrachat } from "@bitxenia/astrachat";

const node = await createAstrachat({
  chatSpace: "bitxenia-chat",
});

const chatList = await node.getChatList();
console.log(chatList);

The chat space name determines where the node places the chats. Creating a new chat using this node, for example, results in a new chat in the bitxenia-chat chat space.

To create a new chat, simply specify a name for it. Additionally, Astrachat supports callback functions to handle frontend events whenever the user receives a new message.

const callback = (message: ChatMessage) => console.log("New: ", message);
await node.createChat("Example chat", onNewMessage: callback);

Now that you've created a chat, you can start sending messages to it. Note that the chat'll only persist in the database after you send your first message. To do that, choose an alias to identify yourself as, and type something.

const text = "Hi from bitxenia :)";
await node.sendMessage("Example chat", text, "Bob");

If you want to connect to a chat that's already made, you can get all its messages with the node:

const messages = await node.getMessages("Example chat");
console.log("Messages", messages);

You can also add a callback function when connecting to an existing chat, so that you can stay up to date with the latest messages sent.

const callback = (message: ChatMessage) => console.log("New: ", message);
const messages = await node.getMessages("Example chat", onNewMessage: callback);

A chat space can contain multiple chats. Astrachat allows the user to list all of them.

const chatList = await node.getChatList();
console.log("All chats: ", messages);

Collaborating

To collaborate on your community's chat space, simply set isCollaborator to true in the createAstrachat arguments. This'll pin all the chats so other users can reach it through your node. This'll help in keeping the chats persistent, and increasing the availability within the IPFS network.

import { createAstrachat } from "@bitxenia/astrachat";

const node = await createAstrachat({
  chatSpace: "bitxenia-chat",
  isCollaborator: true,
});

Documentation

Development

Clone and install dependencies:

git clone [email protected]:bitxenia/astrachat.git
cd astrachat
npm install

Run Tests

npm run test

Build

npm run build

Run multiple nodes in a machine

To be able to run Astrachat in more than one instance per machine, you'll need to change the ports of the instances to be unique. Also, the datastore, blockstore, and data directories'll also need to be unique to the instance.

const datastore = new FsDatastore("./data/node1/datastore");
const blockstore = new FsBlockstore("./data/node1/blockstore");
return await createAstrachat({
  isCollaborator: true,
  datastore,
  blockstore,
  tcpPort: 51001,
  webrtcDirectPort: 51001,
  dataDir: "./data/node1",
});

Contributions

Contributions are welcome, please check the issues to get started.

Troubleshooting

The node can't receive incoming connections and thus can't collaborate

If the node is set to collaborate and it fails to do so, the reason should most likely be a port issue. The LibP2P implementation uses UPnP to automatically open ports and detect the public IP. If the modem is outdated, you'll need to manually open the ports and specify the public IP when creating the node in the createAstrachat function.

The ports that need to be opened manually are:

  • 50001 TCP port, used to receive TCP incoming connections.
  • 50001 UDP port, used to receive WebRTC-Direct incoming connections.

If this doesn't work, your ISP may be using Double NAT, which prevents incoming connections. In this case, you may need to contact your ISP to request a solution.

Other implementations

  • https://github.com/bitxenia/astrachat-eth

License

MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)