MeshKit

Core Quickstart

Create a MeshKit client with @meshkit/core.

Use this quickstart when you need explicit provider and identity wiring. If you only want to store an object from application code, start with the SDK Quickstart instead.

Install

npm install @meshkit/core

Create Infrastructure Wiring

// src/infrastructure/meshkit.ts
import { createMeshkit, LocalDevProvider } from "@meshkit/core";

export function createCoreMeshKit() {
  return createMeshkit({
    provider: new LocalDevProvider(),
    identity: "docs-device",
  });
}

Verify The Client

import { createCoreMeshKit } from "./src/infrastructure/meshkit";

const mesh = await createCoreMeshKit();

const file = await mesh.files.put("core.txt", "Core gives explicit provider control.");
const report = await mesh.doctor.run();

console.log({
  cid: file.cid,
  verified: file.proof.verified,
  doctor: report.ok,
});

Expected shape:

{
  cid: "bafy...",
  verified: true,
  doctor: true
}

What This Proves

This proves that:

  • Core can construct a MeshKitClient from an explicit provider.
  • The provider can store encrypted bytes and proof metadata.
  • The doctor report can inspect the configured provider boundary.
  • Feature code can call the same namespaces exposed through the SDK facade.

What To Change For Production

Replace LocalDevProvider with a real provider configuration and validate it:

import { createMeshkitFromConfig } from "@meshkit/core";
import config from "../../meshkit.config.json" assert { type: "json" };

export function createProductionMeshKit() {
  return createMeshkitFromConfig(config, {
    identity: "service-worker",
  });
}

Keep secrets out of meshkit.config.json; use environment variables or your runtime secret manager.

Common Mistakes

  • Importing Core directly in every feature file instead of centralizing provider construction.
  • Using LocalDevProvider as if it were production storage.
  • Configuring a byte store without a MeshKit metadata boundary.
  • Logging provider tokens or decrypted content while debugging.
  • Skipping mesh.doctor.run() or CLI validation after changing providers.

Next Steps

On this page