{
"repo": "rpc",
"timestamp": "2026-01-16T23:39:55.794Z",
"entryPoint": "index.js",
"exports": {
"packageJson": {
"main": "index.js"
}
},
"api": {
"file": "index.js",
"exports": [
{
"type": "default",
"name": "class"
}
],
"classes": [
{
"name": "HyperswarmRPC"
},
{
"name": "ClientRef"
},
{
"name": "Client"
},
{
"name": "Server"
}
],
"functions": [
{
"name": "wrap"
}
]
},
"readme": {
"content": "# Hyperswarm RPC\n\nSimple RPC over the Hyperswarm DHT, backed by [Protomux](https://github.com/mafintosh/protomux).\n\n```sh\nnpm install @hyperswarm/rpc\n```\n\n## Usage\n\n```js\nconst RPC = require('@hyperswarm/rpc')\n\nconst rpc = new RPC()\n\nconst server = rpc.createServer()\nawait server.listen()\n\nserver.respond('echo', (req) => req)\n\nconst client = rpc.connect(server.publicKey)\nawait client.request('echo', Buffer.from('hello world'))\n// <Buffer 'hello world'>\n```\n\n## API\n\n#### `const rpc = new RPC([options])`\n\nConstruct a new RPC instance.\n\nOptions include:\n\n```js\n{\n // Optional default value encoding.\n valueEncoding: encoding,\n // A Noise keypair that will be used by default to listen/connect on the DHT.\n // Defaults to a new key pair.\n keyPair,\n // A unique, 32-byte, random seed that can be used to deterministically \n // generate the key pair.\n seed: buffer,\n // Optionally overwrite the default bootstrap servers. Not used if a DHT\n // instance is passed instead.\n bootstrap: ['hos",
"sections": [
"intro",
"usage",
"api",
"license"
],
"hasApi": true,
"hasExamples": true,
"exampleCount": 5,
"examples": [
"## Usage",
"## API\n\n#### `const rpc = new RPC([options])`\n\nConstruct a new RPC instance.\n\nOptions include:",
"#### `await rpc.destroy([options])`\n\nFully destroy this RPC instance.\n\nThis will also close any running servers. If you want to force close the instance without waiting for the servers to close pass `{ force: true }`.\n\nIf a DHT instance was passed when constructing the RPC instance, this DHT will *not* be destroyed; the RPC instance will only destroy DHT instances that it itself has constructed.\n\n### Creating clients\n\n#### `const client = rpc.connect(publicKey[, options])`\n\nOptions are the same as [`dht.connect()`](https://github.com/holepunchto/hyperdht#const-encryptedconnection--nodeconnectremotepublickey-options).\n\n#### `client.dht`\n\nThe [`DHT`](https://github.com/holepunchto/hyperdht#api) instance used by the client.\n\n#### `client.rpc`\n\nThe [`ProtomuxRPC`](https://github.com/holepunchto/protomux-rpc#api) instance used by the client.\n\n#### `client.closed`\n\nWhether or not the RPC channel is closed.\n\n#### `client.mux`\n\nThe muxer used by the channel.\n\n#### `client.stream`\n\nThe stream used by the channel.\n\n#### `const response = await client.request(method, value[, options])`\n\nPerform an RPC request, returning a promise that will resolve with the value returned by the request handler or reject with an error.\n\nOptions include:"
]
},
"patterns": [
"peer-discovery",
"dht-discovery",
"stream-multiplexing"
]
}