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/meshkit2. 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.mjsExpected 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 MeshKitThe 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
| Symptom | Likely cause | Fix |
|---|---|---|
| Cannot resolve package | Installed meshkit instead of @meshkit/meshkit | Install the scoped package |
| Read fails for a CID copied from elsewhere | CID was not created by this MeshKit provider/metadata boundary | Read from the same provider setup or migrate the object |
| Output logs sensitive data | App logs decrypted content or private identifiers | Log CIDs, proof summaries, and error codes instead |
| Works locally but not remotely | Local-dev provider was never replaced | Configure and validate production providers |
Next Steps
- Learn the file API: Files
- Store structured app data: Records
- Share with another identity: Sharing
- Understand providers: Provider model
- Prepare production: Production setup