Skip to content

Getting started

zwire ships identical core semantics across TypeScript (@zwire/* on npm) and Rust (zwire* on crates.io) with zero runtime dependencies.

Install the core package (and optionally a UI adapter for React, Vue, Solid, or Svelte):

Terminal window
npm install @zwire/core
# Optional UI framework adapters:
# npm install @zwire/react # or @zwire/vue, @zwire/solid, @zwire/svelte

Create a signal, a derived computed, and an auto-rebasing optimistic layer:

import { atom, batch, computed } from '@zwire/core';
import { createOptimisticLayer } from '@zwire/core/tx';
const balance = atom(1000);
const display = computed(() => `$${balance.get()}`);
const hold = createOptimisticLayer();
hold.update(balance, (b) => b - 150); // UI: $850
// Concurrent authoritative server push -> active optimistic layers auto-rebase!
batch(() => balance.set(1500)); // UI: $1350
// Zero-flicker atomic settle:
hold.settle(() => balance.set(1350));
console.log(display.get()); // "$1350"

Every adapter package peer-depends on @zwire/core and mirrors its subpaths 1:1 (/tx, /collections, /resource, /protocol):

  • @zwire/react — React 18/19 Compiler-safe hooks + concurrent-abort-safe SelectorStabilizer
  • @zwire/vue — Vue 3.5+ read-through customRef + v-model atoms
  • @zwire/solid — Solid 2 read-through accessors + owner-scoped subscriptions
  • @zwire/svelte — Svelte 5.7+ createSubscriber refs + store contract