iroh README

The project's README from github.com/n0-computer/iroh. As one markdown file: README.md.

iroh

less net work for networks

Documentation Crates.io downloads Chat Youtube License: MIT License: Apache 2.0 CI

Docs Site | Rust Docs


What is iroh?

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.

Hole-punching

The fastest route is a direct connection, so if necessary, iroh tries to hole-punch. Should this fail, it can fall back to an open ecosystem of public relay servers. To ensure these connections are as fast as possible, we continuously measure iroh.

Built on QUIC

Iroh uses noq to establish QUIC connections between endpoints. This way you get authenticated encryption, concurrent streams with stream priorities, a datagram transport and avoid head-of-line-blocking out of the box.

Compose Protocols

Use pre-existing protocols built on iroh instead of writing your own:

Getting Started

Rust Library

It's easiest to use iroh from rust. Install it using cargo add iroh, then on the connecting side:

const ALPN: &[u8] = b"iroh-example/echo/0";

let endpoint = Endpoint::bind().await?;

// Open a connection to the accepting endpoint
let conn = endpoint.connect(addr, ALPN).await?;

// Open a bidirectional QUIC stream
let (mut send, mut recv) = conn.open_bi().await?;

// Send some data to be echoed
send.write_all(b"Hello, world!").await?;
send.finish()?;

// Receive the echo
let response = recv.read_to_end(1000).await?;
assert_eq!(&response, b"Hello, world!");

// As the side receiving the last application data - say goodbye
conn.close(0u32.into(), b"bye!");

// Close the endpoint and all its connections
endpoint.close().await;

And on the accepting side:

let endpoint = Endpoint::bind().await?;

let router = Router::builder(endpoint)
    .accept(ALPN.to_vec(), Arc::new(Echo))
    .spawn()
    .await?;

// The protocol definition:
#[derive(Debug, Clone)]
struct Echo;

impl ProtocolHandler for Echo {
    async fn accept(&self, connection: Connection) -> Result<()> {
        let (mut send, mut recv) = connection.accept_bi().await?;

        // Echo any bytes received back directly.
        let bytes_sent = tokio::io::copy(&mut recv, &mut send).await?;

        send.finish()?;
        connection.closed().await;

        Ok(())
    }
}

The full example code with more comments can be found at echo.rs.

Or use one of the pre-existing protocols, e.g. iroh-blobs or iroh-gossip.

Other Languages

If you want to use iroh from other languages, make sure to check out iroh-ffi, the repository for FFI bindings.

Repository Structure

This repository contains a workspace of crates:

License

Copyright 2025 N0, INC.

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

iroh (n0-computer/iroh)

Searching Database…

12.7K ·GitHub
What is this?Iroh is a Rust library that lets you connect to other devices by dialing their public key instead of an IP address; it automatically finds and maintains the fastest connection—direct via hole-punching, or falling back to a relay—built on QUIC.
Is this a full networking stack or just a connection library?It is a core Rust library handling endpoint connectivity (hole-punching plus relays); separate protocol crates like iroh-blobs, iroh-gossip, and iroh-docs are built on top of it for file transfer, pub-sub, and key-value storage.
How do I add it to a Rust project?Run cargo add iroh, then dial by public key on the connecting side and accept connections on the other side. A full working example is in echo.rs.
Can I use iroh from languages other than Rust?Yes, through the iroh-ffi repository, which provides FFI bindings so iroh can be used from other languages.
Does it always get a direct connection?Not always. Iroh tries to hole-punch for a direct path first, but if that fails it falls back to an open ecosystem of public relay servers to keep the connection alive.
What is the iroh-relay crate for?It is the relay client and server implementation that N0 runs in production for the public relays, and you can self-host it too.
How are connections secured?Iroh builds QUIC connections via the noq crate, giving authenticated encryption, concurrent prioritized streams, and a datagram transport out of the box.
What is iroh-dns-server?It's the DNS server implementation powering DNS/Pkarr address lookup for EndpointIds, running in production at dns.iroh.link.
Can iroh move large amounts of data efficiently?The iroh-blobs protocol provides BLAKE3-based content-addressed blob transfer that scales from kilobytes to terabytes.
Size
366.5 MB
Stars
12.7K
Age
4y
Commits · 90 Days