# What Programming Language Is iroh Written In?

> Discover that iroh is written entirely in Rust. Learn how Rust's features enable iroh's high-performance peer-to-peer networking.

- Repository: [number zero/iroh](https://github.com/n0-computer/iroh)
- Tags: getting-started
- Published: 2026-06-23

---

**iroh is implemented entirely in Rust**, utilizing the language's robust type system, async runtime capabilities, and native QUIC integration to deliver high-performance peer-to-peer networking.

The n0-computer/iroh repository is organized as a Cargo workspace, with all core library code residing in `.rs` source files. This Rust-only implementation powers the stack's endpoint management, relay handling, and TLS encryption without relying on native bindings to other languages.

## Rust Implementation and Workspace Structure

The project follows standard Rust conventions with a workspace-level configuration at the repository root. The top-level [`Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/Cargo.toml) defines the workspace members and shared dependencies, confirming the project's exclusive use of Rust's package ecosystem.

### Cargo Workspace Configuration

The repository structure centers on the root [`Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/Cargo.toml), which declares multiple internal crates including `iroh`, `iroh-base`, `iroh-dns`, and `iroh-relay`. Every component uses Cargo as its build system and dependency manager, with version pinning and feature flags managed through standard Rust manifest files.

### Core Source Files

Several key files demonstrate the Rust implementation:

- **[`iroh/src/lib.rs`](https://github.com/n0-computer/iroh/blob/main/iroh/src/lib.rs)** — Exports the main `Endpoint` API and re-exports types from sub-crates, serving as the primary entry point for developers.
- **[`iroh-base/src/lib.rs`](https://github.com/n0-computer/iroh/blob/main/iroh-base/src/lib.rs)** — Contains low-level primitives including cryptographic keys, endpoint IDs, and relay URL types used throughout the networking stack.
- **[`iroh-dns/src/lib.rs`](https://github.com/n0-computer/iroh/blob/main/iroh-dns/src/lib.rs)** — Implements DNS-based address lookup and resolution entirely in Rust.
- **[`iroh-relay/Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/iroh-relay/Cargo.toml)** — Defines the relay server component dependencies, further confirming the Rust ecosystem usage.

All source files use the `.rs` extension and leverage Rust's module system for code organization.

## Why Rust Powers iroh

Rust provides several technical advantages that align with iroh's networking requirements:

- **Memory Safety** — The ownership model prevents data races and memory leaks in concurrent networking code without garbage collection.
- **Async/Await** — First-class support for asynchronous programming enables efficient handling of thousands of concurrent peer connections.
- **Native QUIC** — Rust's ecosystem provides mature QUIC implementations that iroh leverages for transport-layer security and connection migration.
- **Zero-Cost Abstractions** — High-level APIs for endpoints and streams compile down to efficient machine code suitable for resource-constrained environments.

## Code Examples and Usage

The following example demonstrates creating a simple iroh endpoint in Rust, showcasing the language's async patterns:

```rust
use iroh::{Endpoint, EndpointAddr, endpoint::presets};
use n0_error::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Bind an endpoint using the default "number 0" preset.
    let ep = Endpoint::bind(presets::N0).await?;

    // Define a remote address (replace with a real endpoint ID).
    let remote: EndpointAddr = "example-id@relay.n0.com".parse()?;

    // Open a QUIC connection and a bi-directional stream.
    let conn = ep.connect(remote, b"my-alpn").await?;
    let (mut send, mut recv) = conn.open_bi().await?;

    // Exchange a short message.
    send.write_all(b"hello").await?;
    send.finish().await?;
    let msg = recv.read_to_end(usize::MAX).await?;
    println!("Received: {}", String::from_utf8_lossy(&msg));

    // Clean shutdown.
    conn.close(0u8.into(), b"done");
    ep.close().await;
    Ok(())
}

```

To add iroh to your own Rust project, include it in your [`Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/Cargo.toml):

```toml

# Cargo.toml of your own Rust project

[dependencies]
iroh = { git = "https://github.com/n0-computer/iroh", tag = "v0.9.0" }
tokio = { version = "1", features = ["full"] }

```

## Summary

- **iroh is written entirely in Rust**, with no components implemented in other programming languages.
- The repository uses a **Cargo workspace** structure defined in the root [`Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/Cargo.toml) to manage multiple internal crates.
- Core functionality resides in files like [`iroh/src/lib.rs`](https://github.com/n0-computer/iroh/blob/main/iroh/src/lib.rs) and [`iroh-base/src/lib.rs`](https://github.com/n0-computer/iroh/blob/main/iroh-base/src/lib.rs), exposing the `Endpoint` API and low-level networking types.
- Rust's **async/await** syntax and **Tokio** runtime power the library's peer-to-peer connection handling and QUIC implementation.

## Frequently Asked Questions

### Is iroh written entirely in Rust?

Yes, iroh is implemented 100% in Rust according to the n0-computer/iroh source code. Every module, from the core endpoint logic in [`iroh/src/lib.rs`](https://github.com/n0-computer/iroh/blob/main/iroh/src/lib.rs) to the relay server configuration in [`iroh-relay/Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/iroh-relay/Cargo.toml), uses Rust source files and the Cargo build system.

### Can I use iroh from programming languages other than Rust?

While iroh itself is Rust-only, you can interface with it from other languages using Rust's Foreign Function Interface (FFI) capabilities or by creating language-specific bindings. However, the primary and most performant way to use iroh remains direct integration into Rust applications.

### What build system does iroh use?

iroh uses **Cargo**, Rust's official package manager and build system. The workspace is defined in the top-level [`Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/Cargo.toml), with individual crate configurations managing dependencies, feature flags, and build targets across the entire project.

### Does iroh require specific Rust language features?

Yes, iroh requires Rust's **async/await** syntax and runs on the **Tokio** runtime for asynchronous I/O operations. The codebase leverages modern Rust features including strict typing for protocol safety and zero-cost abstractions for network performance.