One of the most powerful features of the dWeb, is how network data is distributed amongst its users. Many developers like Peeps, make an honest effort to ensure that each of their applications, when installed on a user's device, act as a DHT node on the network because it's important to the growth of dWeb's network and further decentralizes the dWeb in the process. Using @dwebswarm/dht makes this easy. In order to integrate
@dwebswarm/dht into your application, do the following:
First you will need to add
@dwebswarm/dht to your application by running:
Become A DHT Node
Within your application, you can utilize the following code to allow for a user's device to act as a dWeb-based DHT node:
That's literally it. Now the user's device, is a DHT node on the dWeb network.
You can actually create your own private dWeb, by launching your own DHT network, using @dwebswarm/cli. You could then use the "bootstrap" parameter within the DHT options, so that new nodes can connect to the right DHT, rather than dWeb's default DHT nodes. You can learn more about the dWebSwarm DHT API, here.
Learn how to programmatically announce a dWeb network address on dWeb's DHT, here.