Getting started
zwire ships identical core semantics across TypeScript (@zwire/* on npm) and Rust (zwire* on crates.io) with zero runtime dependencies.
Install & first example
Section titled “Install & first example”Install the core package (and optionally a UI adapter for React, Vue, Solid, or Svelte):
npm install @zwire/core# Optional UI framework adapters:# npm install @zwire/react # or @zwire/vue, @zwire/solid, @zwire/svelteCreate 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"Add the feature-gated zwire umbrella crate (or individual zero-dep crates such as zwire-core, zwire-tx, zwire-collections, zwire-protocol):
cargo add zwireRun the identical rebaseable optimistic transaction inside a Scope:
use zwire::prelude::*;
let scope = Scope::new();let balance = scope.atom(1_000_i64);let display = scope.computed(move |cx| format!("${}", cx.get(balance)));
let mut hold = OptimisticLayer::new(&scope);hold.update(balance, |b| b - 150); // UI: $850
// Concurrent authoritative server push -> active optimistic layers auto-rebase!scope.set(balance, 1_500);assert_eq!(scope.get(display), "$1350");
// Zero-flicker atomic settle:hold.settle_with(|| scope.set(balance, 1_350));UI framework adapters
Section titled “UI framework adapters”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-safeSelectorStabilizer@zwire/vue— Vue 3.5+ read-throughcustomRef+v-modelatoms@zwire/solid— Solid 2 read-through accessors + owner-scoped subscriptions@zwire/svelte— Svelte 5.7+createSubscriberrefs + store contract
Next steps
Section titled “Next steps”- Why zwire — design goals, honest trade-offs, and what CI verifies.
- Scopes, SSR & Ownership — per-request isolation and
scoped()definitions. - Optimistic Layers & STM Drafts — interactive rebase demo and STM conflict verification.
- Incremental Top-K Collections — interactive 50k-row collection demo.
- Wire Protocol v3 — canonical RFC-8259 JSON hydration and 64-bit integers.
- API Reference — complete TypeScript, Rust, and conformance API surface.