Home

Awesome

<h1 align="center"> <a href="https://libp2p.io"><img width="250" src="https://github.com/libp2p/js-libp2p/blob/main/img/libp2p.png?raw=true" alt="libp2p hex logo" /></a> </h1> <h3 align="center">The JavaScript implementation of the libp2p Networking Stack.</h3> <p align="center"> <a href="http://protocol.ai"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a> <a href="http://libp2p.io/"><img src="https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square" /></a> <a href="http://webchat.freenode.net/?channels=%23libp2p"><img src="https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square" /></a> <a href="https://matrix.to/#/#libp2p-implementers:ipfs.io"><img src="https://img.shields.io/badge/matrix-%23libp2p--implementers%3Aipfs.io-blue.svg?style=flat-square" /> </a> <a href="https://discord.gg/ipfs"><img src="https://img.shields.io/discord/806902334369824788?color=blueviolet&label=discord&style=flat-square" /></a> <a href="https://discuss.libp2p.io"><img src="https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg" /></a> <a href="https://www.npmjs.com/package/libp2p"><img src="https://img.shields.io/npm/dm/libp2p.svg" /></a> <a href="https://www.jsdelivr.com/package/npm/libp2p"><img src="https://data.jsdelivr.com/v1/package/npm/libp2p/badge"/></a> </p> <p align="center"> <a href="https://github.com/libp2p/js-libp2p/actions?query=branch%3Amain+workflow%3ACI+"><img src="https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main&label=ci&style=flat-square" /></a> <a href="https://codecov.io/gh/libp2p/js-libp2p"><img src="https://img.shields.io/codecov/c/github/libp2p/js-libp2p/main.svg?style=flat-square"></a> <br> <a href="https://github.com/feross/standard"><img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square"></a> <a href="https://github.com/RichardLitt/standard-readme"><img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" /></a> <a href=""><img src="https://img.shields.io/badge/npm-%3E%3D7.0.0-orange.svg?style=flat-square" /></a> <a href=""><img src="https://img.shields.io/badge/Node.js-%3E%3D15.0.0-orange.svg?style=flat-square" /></a> <br> </p>

js-libp2p-monorepo <!-- omit in toc -->

libp2p.io Discuss codecov CI

JavaScript implementation of libp2p, a modular peer to peer network stack

Project status

This project has been used in production for years in Ethereum, IPFS, and more. It is actively maintained by multiple organizations and continues to be improved! The API might change, but we strictly follow semver.

The documentation in the main 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.

Want to update libp2p in your project? Check our migrations folder.

Table of contents <!-- omit in toc -->

Background

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:

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.

Roadmap

The js-libp2p roadmap can be found here: https://github.com/libp2p/js-libp2p/blob/main/ROADMAP.md

It represents current projects the js-libp2p maintainers are focused on and provides an estimation of completion targets.

Install

npm install libp2p

Usage

Configuration

For all the information on how you can configure libp2p see CONFIGURATION.md.

Limits

For help configuring your node to resist malicious network peers, see LIMITS.md

Getting started

If you are starting your journey with js-libp2p, read the GETTING_STARTED.md guide.

Tutorials and Examples

You can find multiple examples on the examples repo that will guide you through using libp2p for several scenarios.

Structure

Development

Clone and install dependencies:

> git clone https://github.com/libp2p/js-libp2p.git
> cd js-libp2p
> npm install
> npm run build

Tests

Run unit tests

# run all the unit tsts
> npm test

# run just Node.js tests
> npm run test:node

# run just Browser tests (Chrome)
> npm run test:chrome

Packages

List of packages currently in existence for libp2p

This table is generated using the module package-table with package-table --data=package-list.json.

PackageVersionDepsCICoverage
libp2p
libp2pnpmDepsGitHub CIcodecov
@libp2p/interfacenpmDepsGitHub CIcodecov
transports
@libp2p/tcpnpmDepsGitHub CIcodecov
@libp2p/webrtcnpmDepsGitHub CIcodecov
@libp2p/websocketsnpmDepsGitHub CIcodecov
@libp2p/webtransportnpmDepsGitHub CIcodecov
secure channels
@chainsafe/libp2p-noisenpmDepsGitHub CIcodecov
@libp2p/plaintextnpmDepsGitHub CIcodecov
stream multiplexers
@chainsafe/libp2p-yamuxnpmDepsGitHub CIcodecov
peer discovery
@libp2p/bootstrapnpmDepsGitHub CIcodecov
@libp2p/kad-dhtnpmDepsGitHub CIcodecov
@libp2p/mdnsnpmDepsGitHub CIcodecov
@chainsafe/discv5npmDepsGitHub CIcodecov
content routing
@libp2p/http-v1-content-routingnpmDepsGitHub CIcodecov
@libp2p/delegated-content-routingnpmDepsGitHub CIcodecov
@libp2p/kad-dhtnpmDepsGitHub CIcodecov
peer routing
@libp2p/delegated-peer-routingnpmDepsGitHub CIcodecov
@libp2p/kad-dhtnpmDepsGitHub CIcodecov
utilities
@libp2p/cryptonpmDepsGitHub CIcodecov
data types
@libp2p/peer-idnpmDepsGitHub CIcodecov
@libp2p/peer-recordnpmDepsGitHub CIcodecov
pubsub
@ChainSafe/libp2p-gossipsubnpmDepsGitHub CIcodecov
@libp2p/floodsubnpmDepsGitHub CIcodecov

Used by

<div style="padding: 20px"> <p align="middle"> <a href="https://lodestar.chainsafe.io/"><img width="300" src="https://github.com/ChainSafe/lodestar/blob/unstable/assets/lodestar_icon_text_black_stroke.png?raw=true" /></a> <a href="https://hoprnet.org/"><img width="150" src="https://github.com/hoprnet/hopr-assets/blob/master/v1/logo/hopr_logo_padded.png?raw=true" alt="HOPR Logo" /></a> <a href="https://helia.io/"><img src="https://raw.githubusercontent.com/ipfs/helia/main/assets/helia.png" alt="Helia (IPFS in JavaScript) logo" width="150" /></a> <a href="https://peerbit.org/"><img src="https://github.com/dao-xyz/peerbit/blob/master/docs/peerbit-logo.png" alt="Peerbit logo" width="150" /></a> <a href="https://topology.gg/"><img src="https://avatars.githubusercontent.com/u/157637200" alt="Topology logo" width="150" /></a> </p> </div>

And many others...

Contribute

See CONTRIBUTING.md.

API Docs

License

Licensed under either of