Meshkit class
The multi-node IPFS client returned by init(). All operations use failover automatically.
Meshkit is the main client interface. You get an instance from init().
All storage and IPNS methods retry across healthy nodes in priority order. Key operations (publishName, generateKey, listKeys, listPins) always use the primary node.
Static initializer
import { Meshkit } from '@ipfs-meshkit/meshkit';
const meshkit = await Meshkit.init({
nodes: ['http://127.0.0.1:5001'],
});Use init() (the module function) for Node.js apps — it also handles local daemon startup. Meshkit.init() is the lower-level constructor for environments where you manage the daemon yourself.
Meshkit.init(options: MeshkitInitOptions)
| Property | Type | Description |
|---|---|---|
nodes | string[] | Kubo RPC URLs in priority order (required, at least one). |
headers | Record<string, string> | Optional auth headers for all nodes. |
Properties
activeNodes
readonly activeNodes: readonly string[]The nodes that passed the health check at init, in priority order.
Methods
Storage
| Method | Returns | Description |
|---|---|---|
upload(data: Uint8Array) | Promise<string> | Upload bytes; returns the CID. Uses failover. |
retrieve(cid: string) | Promise<Uint8Array> | Retrieve content by CID. Uses failover. |
pin(cid: string) | Promise<void> | Pin a CID. Uses failover. |
listPins() | Promise<string[]> | List pinned CIDs on the primary node. |
IPNS
| Method | Returns | Description |
|---|---|---|
publishName(value, options?) | Promise<IpnsPublishResult> | Publish IPNS record. Primary node only. |
resolveName(name, options?) | Promise<string> | Resolve an IPNS name to an /ipfs/... path. Uses failover. |
resolveAndRetrieve(name, options?) | Promise<Uint8Array> | Resolve then retrieve. Uses failover. |
generateKey(name, options?) | Promise<IpnsKey> | Create a named signing key. Primary node only. |
listKeys() | Promise<IpnsKey[]> | List keystore. Primary node only. |
See the IPNS API reference for full option types.