npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@calimero-network/calimero-sdk-js

v0.1.2

Published

Core SDK for building Calimero P2P applications

Readme

@calimero-network/calimero-sdk-js

Core SDK for building Calimero P2P applications with automatic CRDT-based state synchronization.

Installation

npm install @calimero-network/calimero-sdk-js
# or
pnpm add @calimero-network/calimero-sdk-js

Usage

import { State, Logic, Init, View, createUnorderedMap } from '@calimero-network/calimero-sdk-js';
import type { UnorderedMap } from '@calimero-network/calimero-sdk-js/collections';

@State
export class MyApp {
  items: UnorderedMap<string, string> = createUnorderedMap();
}

@Logic(MyApp)
export class MyAppLogic extends MyApp {
  @Init
  static initialize(): MyApp {
    return new MyApp();
  }

  set(key: string, value: string): void {
    this.items.set(key, value);
  }

  @View()
  get(key: string): string | null {
    return this.items.get(key) ?? null;
  }
}

Use the helper factories (createUnorderedMap, createVector, createCounter, createLwwRegister, createUnorderedSet) to initialize CRDT collections directly on your state fields. Avoid constructor side effects; the decorators will hydrate the state instance on each call.

Decorate read-only methods with @View() so the runtime skips persistence for calls that do not mutate state. Views still run inside the same execution sandbox but won’t emit storage deltas, which keeps the DAG compact and avoids redundant writes.

All values, return payloads, and collection snapshots are serialized with Calimero’s Borsh encoder. Nested CRDTs or complex objects are supported as long as you keep data structures serializable (avoid functions, symbols, etc.).

Private Storage

Use createPrivateEntry for node-local data that should not replicate across the network:

import { createPrivateEntry } from '@calimero-network/calimero-sdk-js';

const secrets = createPrivateEntry<{ token: string }>('private:secrets');

secrets.getOrInit(() => ({ token: '' }));
secrets.modify(
  value => {
    value.token = 'latest-token';
  },
  () => ({ token: '' })
);

Values are serialized with the same helper as service state, but they are written via storageRead/storageWrite directly and never appear in CRDT deltas.

Documentation

Updating the storage shim

@calimero-network/calimero-sdk-js ships a prebuilt storage_wasm.wasm that mirrors the Rust storage-wasm crate. Whenever the Rust runtime or storage crate changes, regenerate the artifact and the C header that embeds it. From the repository root:

  1. Build the updated shim for WASI:
cargo build --release --target wasm32-wasip1 -p storage-wasm
  1. Copy the resulting WASM into the SDK package:
cp target/wasm32-wasip1/release/storage_wasm.wasm calimero-sdk-js/packages/sdk/src/wasm/storage_wasm.wasm
  1. Refresh the header used by the CLI builder:
xxd -i calimero-sdk-js/packages/sdk/src/wasm/storage_wasm.wasm > calimero-sdk-js/packages/cli/builder/storage_wasm.h

Both the SDK and the Calimero runtime load this shim at build time, so keep the binary and header in sync with the latest runtime changes before publishing packages or rebuilding Docker images.

See the main repository documentation for complete guides and API reference.

License

Apache-2.0