Skip to content
minip2p
Esc
navigateopen⌘Jpreview
On this page

Install

Install minip2p for Rust and choose the network capabilities your application needs.

minip2p requires Rust 1.91 or newer. The package is named minip2p-rs on crates.io and imported as minip2p in Rust code.

Install the default endpoint

cargo add minip2p-rs

The default endpoint listens over QUIC and includes peer authentication, Identify, Ping, and custom protocol streams.

use minip2p::Endpoint;

fn main() -> Result<(), minip2p::Error> {
    let node = Endpoint::builder().bind_quic("127.0.0.1:0")?;
    println!("local peer: {}", node.peer_id());
    Ok(())
}

Continue to Connect two peers if that is enough for the application.

Add an optional capability

Add only the capabilities the application uses:

Need Install Enable on the endpoint
TCP cargo add minip2p-rs --features tcp Bind a TCP listener.
Relay paths and NAT traversal cargo add minip2p-rs --features nat Configure a relay, an AutoNAT server, or both.
Pubsub cargo add minip2p-rs --features pubsub Call .pubsub() or provide a pubsub configuration.
Signed discovery cargo add minip2p-rs --features discovery Call .discovery() or provide a discovery configuration.
Local mDNS cargo add minip2p-rs --features mdns Call .mdns() or provide an mDNS configuration.

A Cargo feature makes the capability available. The corresponding builder method turns it on for an endpoint. The feature matrix lists the exact methods and required network infrastructure.

Run without an operating system

For a no_std + alloc endpoint over smoltcp:

cargo add minip2p-rs --no-default-features --features smoltcp

The host supplies network I/O, monotonic time, and secure entropy. Continue to Embedded devices for the complete setup.

See the feature matrix when combining capabilities.

Last updated on September 7, 2026

Was this page helpful?