less net work for networks

Iroh is a library for building on direct connections between devices, putting more control in the hands of your users.

DIRECTDIRECTRELAYDIRECT

Connect any two devices on the planet

Iroh gives you an API for dialing by public key. You say “connect to that phone”, iroh will find & maintain the fastest connection for you, regardless of where it is.

“In stark contrast to other p2p & dweb technologies we've played with - which are exciting due to their implications for the future - Iroh brought instant gains in our present."

- weird.one

Compose your own tailor-made protocol stack

An ecosystem of ready-made, composable protocols are built on top of iroh.
Mix & match to get the feature set you need.

Build your own protocol

Don't see a protocol you need? Build your own! Iroh gives you a reliable foundation for building distributed systems that reach the edge. The rest is up to you.

Protocol Docs

Continuously Measured

All commits to iroh's main branch run through a growing set of simulations & tests

Iroh Perf Site

Real World Use

Iroh is running in production on hundreds of thousands of devices, on all major platforms.

Delta Chat

Delta Chat

Iroh powers multi-device backup & live connections for in-chat WebXDC apps

Build in your language

Iroh supports a growing set of languages, embedding nodes directly in your project without any need to call out to an external API

Start Building

hello

import { argv } from 'process'
import { Iroh, BlobTicket } from '@number0/iroh'

// serve & fetch data with iroh, from any two devices in the world
// run this example from any two computers, and iroh will connect them!
(async () => {
  // create a new node with default protocols
  const node = await Iroh.memory();

  // Choose between client & server roles based on the presence of a download CLI argument
  if (argv.length > 2) {
    
    // we have a download argument. Fetch some data!
    let ticket = BlobTicket.fromString(argv[2]);
    console.log(`fetching hash '${ticket.hash}' from node: '${ticket.nodeAddr.nodeId.toString()};`);

    // download the data
    await node.blobs.download(ticket.hash, ticket.asDownloadOptions(), (_err) => {});

    // read the data
    const data = await node.blobs.readToBytes(ticket.hash);
    console.log("data:", new TextDecoder().decode(new Uint8Array(data)));

  } else {

    // no download argument. Serve some data that says "Hello, world!"
    const data = Array.from(new TextEncoder().encode('Hello, World!'));
    const result = await node.blobs.addBytes(data);
    // create a "ticket" for sharing data with another node
    const ticket = await node.blobs.share(result.hash, result.format, 'RelayAndAddresses');

    console.log(`server running. in another terminal run:\n\nnode hello.js ${ticket.toString()}`);
    // wait for ctrl+c
    await new Promise((resolve) => {
      process.on('SIGINT', () => { resolve() });
      setInterval(() => {}, 1000);
    });
    process.exit();
  }
})();

From the Blog