JavaScript implementation of libp2p, a modular peer to peer network stack
- Structure
- Background
- Roadmap
- Install
- Usage
- Development
- Used by
- Contribute
- API Docs
- License
- Contribution
/docDocs for libp2p/examples/auto-relayShows how to configure relayed connections/examples/chatAn example chat app using libp2p/examples/connection-encryptionAn example of how to configure connection encrypters/examples/delegated-routingHow to configure libp2p delegated routers/examples/discovery-mechanismsHow to configure peer discovery mechanisms/examples/echoAn example echo app/examples/peer-and-content-routingHow to use peer and content routing/examples/pnetHow to configure a libp2p private network/examples/protocol-and-stream-muxingHow to use multiplex protocols streams/examples/pubsubAn example using libp2p pubsub/examples/transportsAn example using different types of libp2p transport/interopMultidimension Interop Test/packages/cryptoCrypto primitives for libp2p/packages/interfaceThe interface implemented by a libp2p node/packages/interface-compliance-testsCompliance tests for JS libp2p interfaces/packages/interface-internalInterfaces implemented by internal libp2p components/packages/kad-dhtJavaScript implementation of the Kad-DHT for libp2p/packages/keychainKey management and cryptographically protected messages/packages/libp2pJavaScript implementation of libp2p, a modular peer to peer network stack/packages/loggerA logging component for use in js-libp2p modules/packages/metrics-prometheusCollect libp2p metrics for scraping by Prometheus or Graphana/packages/multistream-selectJavaScript implementation of multistream-select/packages/peer-collectionsStores values against a peer id/packages/peer-discovery-bootstrapPeer discovery via a list of bootstrap peers/packages/peer-discovery-mdnsNode.js libp2p mDNS discovery implementation for peer discovery/packages/peer-idImplementation of @libp2p/interface-peer-id/packages/peer-id-factoryCreate PeerId instances/packages/peer-recordUsed to transfer signed peer data across the network/packages/peer-storeStores information about peers libp2p knows on the network/packages/protocol-perfImplementation of Perf Protocol/packages/pubsublibp2p pubsub base class/packages/pubsub-floodsublibp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network)./packages/stream-multiplexer-mplexJavaScript implementation of https://github.com/libp2p/mplex/packages/transport-tcpA TCP transport for libp2p/packages/transport-webrtcA libp2p transport using WebRTC connections/packages/transport-websocketsJavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec/packages/transport-webtransportJavaScript implementation of the WebTransport module that libp2p uses and that implements the interface-transport spec/packages/utilsPackage to aggregate shared logic and dependencies for the libp2p ecosystem
We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉..
The documentation in the master branch may contain changes from a pre-release. If you are looking for the documentation of the latest release, you can view the latest release on npm, or select the tag in github that matches the version you are looking for.
Want to get started? Check our GETTING_STARTED.md guide and examples folder.
Want to update libp2p in your project? Check our migrations folder.
libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, devs have long had to make custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API.
We are in the process of writing better documentation, blog posts, tutorials and a formal specification. Today you can find:
- libp2p.io
- docs.libp2p.io
- Specification (WIP)
- Discussion Forums
- Talks
- Articles
To sum up, libp2p is a "network stack" -- a protocol suite -- that cleanly separates concerns, and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability. libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.
The js-libp2p roadmap can be found here: https://github.com/libp2p/js-libp2p/blob/master/ROADMAP.md
It represents current projects the js-libp2p maintainers are focused on and provides an estimation of completion targets.
It is complementary to the overarching libp2p project roadmap: https://github.com/libp2p/specs/blob/master/ROADMAP.md
npm install libp2pFor all the information on how you can configure libp2p see CONFIGURATION.md.
For help configuring your node to resist malicious network peers, see LIMITS.md
If you are starting your journey with js-libp2p, read the GETTING_STARTED.md guide.
You can find multiple examples on the examples folder that will guide you through using libp2p for several scenarios.
Clone and install dependencies:
> git clone https://github.com/libp2p/js-libp2p.git
> cd js-libp2p
> npm install
> npm run build# run all the unit tsts
> npm test
# run just Node.js tests
> npm run test:node
# run just Browser tests (Chrome)
> npm run test:chromeList of packages currently in existence for libp2p
This table is generated using the module
package-tablewithpackage-table --data=package-list.json.
| Package | Version | Deps | CI | Coverage |
|---|---|---|---|---|
| libp2p | ||||
libp2p |
||||
@libp2p/interface-libp2p |
||||
| transports | ||||
@libp2p/tcp |
||||
@libp2p/webrtc |
||||
@libp2p/websockets |
||||
@libp2p/webtransport |
||||
| secure channels | ||||
@chainsafe/libp2p-noise |
||||
| stream multiplexers | ||||
@libp2p/mplex |
||||
@chainsafe/libp2p-yamux |
||||
| peer discovery | ||||
@libp2p/bootstrap |
||||
@libp2p/kad-dht |
||||
@libp2p/mdns |
||||
@chainsafe/discv5 |
||||
| content routing | ||||
@libp2p/http-v1-content-routing |
||||
@libp2p/ipni-content-routing |
||||
@libp2p/delegated-content-routing |
||||
@libp2p/kad-dht |
||||
| peer routing | ||||
@libp2p/delegated-peer-routing |
||||
@libp2p/kad-dht |
||||
| utilities | ||||
@libp2p/crypto |
||||
| data types | ||||
@libp2p/peer-id |
||||
@libp2p/record |
||||
@libp2p/peer-record |
||||
| pubsub | ||||
@ChainSafe/libp2p-gossipsub |
||||
@libp2p/floodsub |
And many others...
The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:
- Go through the modules and check out existing issues. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
- Perform code reviews. Most of this has been developed by @diasdavid, which means that more eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
- Add tests. There can never be enough tests.
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

