You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@libp2p/kad-dht

Package Overview
Dependencies
Maintainers
6
Versions
882
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/kad-dht

JavaScript implementation of the Kad-DHT for libp2p

Source
npmnpm
Version
10.0.4
Version published
Weekly downloads
16K
-17.65%
Maintainers
6
Weekly downloads
 
Created
Source

@libp2p/kad-dht

libp2p.io Discuss codecov CI

JavaScript implementation of the Kad-DHT for libp2p

Table of contents

Install

$ npm i @libp2p/kad-dht

Browser <script> tag

Loading this module through a script tag will make it's exports available as Libp2pKadDht in the global namespace.

<script src="https://unpkg.com/@libp2p/kad-dht/dist/index.min.js"></script>
> npm i @libp2p/kad-dht

Use in Node.js

import { create } from '@libp2p/kad-dht'

API

See https://libp2p.github.io/js-libp2p-kad-dht for the auto generated docs.

The libp2p-kad-dht module offers 3 APIs: Peer Routing, Content Routing and Peer Discovery.

Custom secondary DHT in libp2p

import { createLibp2pNode } from 'libp2p'
import { kadDHT } from '@libp2p/kad-dht'

const node = await createLibp2pNode({
  services: {
    dht: kadDHT()
  }
  //... other config
})
await node.start()

for await (const event of node.dht.findPeer(node.peerId)) {
  console.info(event)
}

Note that you may want to supply your own peer discovery function and datastore

Peer Routing

Content Routing

Peer Discovery

Spec

js-libp2p-kad-dht follows the libp2p/kad-dht spec and implements the algorithms described in the IPFS DHT documentation.

API Docs

License

Licensed under either of

Contribution

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.

Keywords

IPFS

FAQs

Package last updated on 16 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts