Open-source project
libp2p/rust-libp2p avatar
libp2p/rust-libp2p

rust-libp2p: adopting the Rust libp2p stack

The Rust Implementation of the libp2p networking stack.

5,613 stars1,263 forksRustMIT

At a glance

What is it?
rust-libp2p is the Rust implementation of the libp2p networking stack, a workspace of transports, muxers, and application protocols. It is the right base when you need peer-to-peer connectivity you control, and the wrong one when a client-server socket would do.
Who is it for?
Adopt rust-libp2p if you are building a peer-to-peer network in Rust and want transports, multiplexing, and application protocols behind one workspace rather than assembled by hand. Do not adopt it if your topology is a client talking to your own server, or if you need a stable API for a long-lived product without a migration budget.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What rust-libp2p solves, and for whom

A peer-to-peer network needs more than a socket. Two nodes have to find each other, agree on an identity, encrypt the link, multiplex several conversations over it, and then speak an application protocol on top. rust-libp2p packages that whole ladder as a Rust workspace, so an application author writes a NetworkBehaviour and inherits the rest. The README describes the repository as the central place for Rust development of the libp2p spec, and points to docs.rs/libp2p as the main documentation.

The audience is narrow and specific. The README's notable users list reads like a map of the problem space: Filecoin's Forest, the Lighthouse Ethereum consensus client, Substrate and Polkadot, a Bitcoin-Monero atomic swap, IPFS implementations. These are systems where no single party owns the network and where nodes must connect without a central rendezvous. If you are writing a web app that talks to your own API, none of this applies to you.

The cost of that generality is surface area. The workspace has separate directories for core, transports, muxers, swarm, protocols, and misc, and the root Cargo.toml lists dozens of members, from transports/quic and transports/webrtc to protocols/gossipsub and protocols/kad. You do not have to learn all of them, but you do have to choose among them.

How the stack is layered: core, swarm, protocols

The architecture is a dependency chain, and understanding it saves time. At the bottom, core/ implements libp2p-core with its Transport and StreamMuxer APIs, which the README says almost all other crates depend on. transports/ holds the wire protocols (TCP, QUIC, WebSocket, WebRTC, WebTransport) and the upgrade layers for authenticated encryption and compression. muxers/ holds stream multiplexers such as yamux and mplex, which the README notes are mandatory Transport upgrades.

Above that sits swarm/, the implementation of libp2p-swarm, whose central interfaces are NetworkBehaviour and ConnectionHandler. This is where your application logic lives. protocols/ then provides ready-made behaviours: identify, ping, Kademlia, gossipsub, request-response, relay, rendezvous, autonat, dcutr, mdns. A typical node combines several of them, and swarm-derive generates the plumbing that dispatches events to each.

The data flow is event-driven. A Transport produces a connection, a muxer splits it into substreams, the swarm negotiates a protocol on a substream, and your NetworkBehaviour receives a polled event. Nothing in this repository is a server framework; there is no request handler and no routing table you configure by hand. That is a deliberate inversion, and it is the main thing newcomers misread.

Installing rust-libp2p and running a first example

The README does not give an install command. It points to docs.rs/libp2p for documentation and to the examples folder for small binaries showcasing the protocols. The crate is published as libp2p, so adding it to a project is a normal Cargo dependency. The workspace declares rust-version = 1.88.0 and edition = 2024, so a toolchain at least that new is required.

For a first real use, the repository's own examples are the shortest path. The workspace Cargo.toml lists examples/ping among its members, and the examples README describes the folder as worked examples of built-in application protocols with common Transport configurations. From a checkout of the repository, the ping example builds and runs as a workspace member. What you should see is a peer id for the listening node and a sequence of ping round trips; if that works, the transport, muxer, and swarm layers are all functioning.

To use the library in your own crate instead, the dependency is the published libp2p crate. The repository does not state a version constraint for consumers, so take the version from the release you intend to track; v0.57.0 was published on 2026-09-11, and the two before it were v0.56.0 in June 2025 and v0.55.0 in January 2025. Check the release notes before pinning, because libp2p releases have historically changed public APIs between minor versions.

Where rust-libp2p is the wrong tool

The clearest failure mode is picking it for a topology it was not designed for. If every node ultimately talks to infrastructure you operate, libp2p gives you peer discovery, NAT traversal, and protocol negotiation you will never exercise, and you pay for them in compile time and in concepts. A plain TCP or HTTP client is smaller and easier to reason about.

The second limitation is API stability. Three minor releases in the period covered here, v0.55.0, v0.56.0, and v0.57.0, means a dependency bump can require code changes. The README does not document a deprecation window or a stability policy, so anyone planning a multi-year product should treat upgrades as scheduled work rather than background noise. The CHANGELOG.md at the repository root is where that work starts.

Third, the browser story is partial. The workspace contains transports/webrtc-websys, transports/websocket-websys, and transports/webtransport-websys, plus wasm-tests/webtransport-tests, which indicates wasm targets are supported. But the README does not describe the constraints of those targets, and a Rust service and a browser node do not get the same transport set. Verify per platform rather than assuming parity.

Finally, there is no operational layer. No metrics endpoint ships as a default, no health check, no admin interface. misc/metrics exists as a crate, but wiring it is your job.

rust-libp2p against go-libp2p and other implementations

libp2p is a specification with several implementations, and the choice between them is mostly a language and runtime decision. go-libp2p is the Go implementation; its concurrency model is goroutines and channels, and its garbage collector shapes latency in a way a Rust service does not have to accept. If your team writes Go, porting to Rust buys you little.

The difference that matters in practice is how each implementation exposes the stack. rust-libp2p makes you implement NetworkBehaviour and compose behaviours through swarm-derive, which is a compile-time, typed arrangement: the set of protocols a node speaks is fixed in the type. Go's equivalent is more dynamic. Neither is better in the abstract, but the Rust version makes adding a protocol a code change across several files.

Within Rust, the alternative to rust-libp2p is rolling your own: a QUIC library plus your own discovery and protocol negotiation. That is a real option if you need exactly one transport and one protocol, and it removes the workspace's API churn. The trade is that you reimplement peer identity, multiaddresses, and protocol negotiation, which is precisely the work the core/ and swarm/ crates already did.

Note also that this repository is a shared spec implementation, not a product. interop-tests and hole-punching-tests exist as workspace members, which tells you cross-implementation compatibility is treated as a first-class concern rather than an afterthought.

Maintenance, releases, and licence

The repository is not archived, and the last push was on 2026-09-21, one day before this writing, so the codebase is being changed. The README names two maintainers, Elena Frank and João Oliveira, and points to open maintainer calls and biweekly libp2p community calls for synchronous discussion. Security issues have a dedicated private reporting path through GitHub security advisories, and the README explicitly asks that they not be filed as public issues.

Upgrade cost is the practical concern. Because minor versions have landed roughly every five to eight months across the releases shown, a team should budget for reading CHANGELOG.md and recompiling on that cadence. The workspace's rust-version = 1.88.0 is a floor, not a ceiling, but it does mean an old toolchain blocks you entirely.

The licence is MIT, which is permissive and compatible with closed-source use. That is the extent of what the repository states; questions about patent grants, attribution in distributed binaries, or interaction with your own dependencies belong with your legal counsel, not with this review. The root also carries deny.toml, which suggests dependency licence and advisory checks run in CI.

Editorial conclusion

Adopt rust-libp2p if you are building a peer-to-peer network in Rust and want transports, multiplexing, and application protocols behind one workspace rather than assembled by hand. Do not adopt it if your topology is a client talking to your own server, or if you need a stable API for a long-lived product without a migration budget. Before committing, read the release notes for v0.57.0, check the libp2p-core Transport and StreamMuxer traits in core/, and build one example from examples/ against your target platform, including wasm if that matters to you.

Frequently asked questions

What is rust-libp2p used for?

It is the Rust implementation of the libp2p networking stack, used to build peer-to-peer applications that need discovery, encrypted connections, stream multiplexing, and application protocols without a central server. The README lists users including Forest, Lighthouse, Substrate, and several IPFS-related projects.

How do I install rust-libp2p?

The README does not give install steps. The crate is published as libp2p, so you add it as a Cargo dependency, and the workspace requires rust-version 1.88.0 and edition 2024. The repository's examples folder is the recommended starting point.

What Rust version does rust-libp2p need?

The workspace Cargo.toml sets rust-version = 1.88.0 and edition = 2024, so a toolchain at least that new is required to build it.

Does rust-libp2p support WebRTC and QUIC?

Yes. The workspace includes transports/quic, transports/webrtc, transports/webrtc-websys, transports/websocket, transports/websocket-websys, and transports/webtransport-websys as members. The README does not describe platform-specific constraints, so verify behaviour on your target rather than assuming parity.

Official sources

  1. libp2p/rust-libp2p on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/libp2p-rust-libp2p.svg)](https://hysenlabs.com/projects/libp2p-rust-libp2p)