init() The main entry point for connecting to Kubo with optional local daemon startup.
import { init } from '@ipfs-meshkit/meshkit' ;
const { meshkit , localNode } = await init (options);
init() is the primary entry point for Node.js apps. It connects to one or more Kubo nodes, optionally starts a local daemon, and returns a ready-to-use Meshkit instance.
function init ( options ?: MeshkitBootstrapOptions ) : Promise < MeshkitBootstrapResult >
Property Type Default Description nodesstring[][]Kubo RPC URLs in priority order. Optional when localNode is set. localNodeboolean | StartIPFSNodeOptions— Start or attach to a local Kubo daemon. When true, uses 127.0.0.1:5001 and ./.ipfs repo. headersRecord<string, string>— Request headers sent to every node (e.g. RPC auth).
Property Type Description meshkitMeshkitConnected client with failover across healthy nodes. localNodeIPFSNodeHandle | undefinedPresent when localNode was requested.
const { meshkit , localNode } = await init ({ localNode: true });
const { meshkit } = await init ({
nodes: [ 'https://kubo.example.com:5001' ],
headers: { Authorization: 'Bearer token' },
});
const { meshkit , localNode } = await init ({
localNode: true ,
nodes: [ 'https://backup.example.com:5001' ],
});
const { meshkit , localNode } = await init ({
localNode: {
port: 5001 ,
repo: '/data/ipfs' ,
readyTimeoutMs: 60000 ,
},
});
Condition Thrown No nodes and no localNode MeshkitError: At least one node URL is requiredAll nodes unreachable MeshkitError with per-node causesDaemon fails to start MeshkitNodeError