Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ipfs-swarm-bind-shim with all npm packages installed. Try it out:

var ipfsSwarmBindShim = require("ipfs-swarm-bind-shim")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ipfs-swarm-bind-shim v0.1.0

A poor mans shim for a missing swarm.bind command


Build Status dependencies Status JavaScript Style Guide

A poor mans shim for a missing swarm.bind command

Stay connected to a minimum number of peers. Periodically checks for connectivity and if not connected to the minimum it'll (re)connect.

⚠️ No tests yet! Might not even work!


npm install ipfs-swarm-bind-shim


const swarmBind = require('ipfs-swarm-bind-shim')


// addresses of peers we want to stay connected to
// n.b. must include peer ID!
const addrs = [

const cancel = await swarmBind(ipfs, addrs, {
  minConnections: 1, // minimum number of peers from the list this node should be connected to (default addrs.length)
  checkInterval: 1000 * 60 // (ms) time between connectivity checks

// ipfs will now be connected to minConnections peers
// and will monitor and re-connect.

// later...

cancel() // unbind (stop checking and connecting)


Feel free to dive in! Open an issue or submit PRs.


MIT © Alan Shaw


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free