Need help with ipfs-pubsub-room?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

248 Stars 36 Forks MIT License 120 Commits 25 Opened issues


IPFS Pubsub room

Services available


Need anything else?

Contributors list


made by Protocol Labs Freenode Build Status

Creates a room based on a LibP2P pub-sub channel. Emits membership events, listens for messages, broadcast and direct messeges to peers.

(Demo video)


$ npm install ipfs-pubsub-room


Creating a pubsub room from a LibP2P node

const Room = require('ipfs-pubsub-room')
const Libp2p = require('libp2p')

const libp2p = new Libp2p({ ... }) await libp2p.start()

// libp2p node is ready, so we can start using ipfs-pubsub-room const room = Room(libp2p, 'room-name')

Creating a pubsub room from an IPFS node

const Room = require('ipfs-pubsub-room')
const IPFS = require('ipfs')

const ipfs = await IPFS.create({ ... }) const room = Room(ipfs, 'room-name')

Once we have a room we can listen for messages

room.on('peer joined', (peer) => {
  console.log('Peer joined the room', peer)

room.on('peer left', (peer) => { console.log('Peer left...', peer) })

// now started to listen to room room.on('subscribed', () => { console.log('Now connected!') })


Room (libp2p:LibP2P, roomName:string, options:object)

  • libp2p
    : LibP2P node. Must have pubsub activated
  • roomName
    : string, global identifier for the room
  • options
    : object:
    • pollInterval
      : interval for polling the pubsub peers, in ms. Defaults to 1000.
const room = Room(libp2p, 'some-room-name')


Broacasts message (string or buffer).

room.sendTo(cid, message)

Sends message (string or buffer) to peer.

async room.leave()

Leaves room, stopping everything.


Returns an array of peer identifiers (strings).


Returns a boolean indicating if the given peer is present in the room.

room.on('message', (message) => {})

Listens for messages. A

is an object containing the following properties:
  • from
    (string): peer id
  • data
    (Buffer): message content

room.on('peer joined', (cid) => {})

Once a peer has joined the room.

room.on('peer left', (cid) => {})

Once a peer has left the room.

room.on('subscribed',() => {})

Once your program has subscribed the topic and announced through IPFS pubsub.



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.