MeshKit

SDK Quickstart

Store and read encrypted content with @meshkit/meshkit.

This quickstart stores and reads one encrypted object using the SDK facade and the local development provider.

Use it to prove the MeshKit round trip before choosing production providers or runtime-specific packages.

1. Install

npm install @meshkit/meshkit

2. Create A Script

Create quickstart.mjs:

import { meshkit } from "@meshkit/meshkit";

const mesh = await meshkit({
  identity: "quickstart-device",
});

const saved = await mesh.files.put("notes/intro.txt", "MeshKit encrypts before storage.", {
  contentType: "text/plain",
});

const opened = await mesh.files.get(saved.cid);

console.log({
  cid: saved.cid,
  encrypted: saved.encrypted,
  provider: saved.proof.provider,
  text: await opened.text(),
});

3. Run It

node quickstart.mjs

Expected shape:

{
  cid: "bafy...",
  encrypted: true,
  provider: "local-dev",
  text: "MeshKit encrypts before storage."
}

The exact CID can differ. The important signals are encrypted: true, a provider proof, and a successful decrypted read.

What This Proves

The quickstart proves the smallest MeshKit workflow:

plaintext string
-> MeshKit client
-> encrypted envelope
-> local development provider
-> CID and proof
-> decrypted read through MeshKit

The provider stores encrypted MeshKit envelope bytes. Your application stores the returned CID if it needs to read, share, audit, or persist the content later.

What This Does Not Prove

This quickstart does not prove production readiness:

  • It uses the local development provider.
  • It does not configure a MeshKit-compatible metadata service.
  • It does not validate gateway retrieval, pinning, Filecoin persistence, policy checks, or mobile key storage.
  • It does not create recipient identities or share capsules.

Move to provider setup before making production claims.

Add It To An App

In application code, keep client creation small:

// src/lib/meshkit.ts
import { meshkit } from "@meshkit/meshkit";

export function createMeshStorage() {
  return meshkit({
    identity: "app-device",
  });
}

Feature code can then call the namespace it needs:

const mesh = await createMeshStorage();
const saved = await mesh.files.put("avatar.png", imageBytes, {
  contentType: "image/png",
});

Common First Errors

SymptomLikely causeFix
Cannot resolve packageInstalled meshkit instead of @meshkit/meshkitInstall the scoped package
Read fails for a CID copied from elsewhereCID was not created by this MeshKit provider/metadata boundaryRead from the same provider setup or migrate the object
Output logs sensitive dataApp logs decrypted content or private identifiersLog CIDs, proof summaries, and error codes instead
Works locally but not remotelyLocal-dev provider was never replacedConfigure and validate production providers

Next Steps

On this page