v0 · Developer PreviewPinna is under active development. APIs may change between releases.
$done$label<Row>Write the docs×$done$label<Row>✓ Ship the site×$done$label<Row>Measure Hermes×$done$label<Row>✓ Run conformance×$done$label<Row>Check the tarba…×$done$label<Row>✓ Bench on No…×$count6$left3$allDonefalse$todosrealm

toggle() writes one $done → $label recomputed once → one <Row> of six re-rendered. Tap a todo to toggle it; × removes it.

Reactive statethat’s hardto get wrong.

Pinna is synchronous state for domain models, built so the usual state bugs cannot happen and the rest fail where you, or your agent, can see them.

a todo, the row that renders it, and its realm
import { box, computed, createRealm, Model, type Realm, update } from "@frondruntime/pinna";
import { useValue } from "@frondruntime/pinna-react";
import { memo } from "react";
import { ListItem } from "./ui.tsx"; // the app's own list item: an <li> with a button

class Todo extends Model {
  readonly $done = box(this.realm, false); // a box: the square on each branch
  // A computed value: the diamond. It reads $done, so a line runs from the box to it.
  readonly $label = computed(this.realm, (read) =>
    read(this.$done) ? `✓ ${this.title}` : this.title,
  );

  constructor(
    realm: Realm,
    readonly id: string,
    readonly title: string,
  ) {
    super(realm);
  }

  toggle(): void {
    update(this.realm, (read, write) => write(this.$done, !read(this.$done)));
  }
}

// The row reads $label, so it re-renders only when its own label changes.
const Row = memo(function Row({ todo }: { readonly todo: Todo }) {
  return <ListItem onPress={() => todo.toggle()}>{useValue(todo.$label)}</ListItem>;
});

const realm = createRealm(); // the stem: the six todos of the graph live in it
const site = new Todo(realm, "2", "Ship the site");
site.toggle(); // the lit branch: its $label recomputes once, and one <Row> of six re-renders
explicit

Reads and writes are explicit. A mistake is loud.

Pinna is glitch-free, at the cost of a call at every read, which the tables below measure.

A mistake is a type error or an error that says where the call belongs; the few that pass are listed. Agents get the rules as AGENTS.md and the documentation as llms-full.txt.

A read says it is a read.

An observable is not its value. A computed value reads through read, a component through a hook; math or a comparison on the observable itself is a type error.

a computed value, and two that forgot read
import { box, computed } from "@frondruntime/pinna";

const $price = box(realm, 12);
const $quantity = box(realm, 3);

// A computed value reads through read, and recomputes when either box changes.
const $total = computed(realm, (read) => read($price) * read($quantity)); // 36

// A box used as its value
const $broken = computed(realm, () => $price * $quantity);^^^^^^ type error TS2362if ($total > 30) {^^^^^^^^^^^ type error TS2365  notify();
}

A write has one place.

Boxes have no setters: only update hands out write. An update that throws is undone, so a half-finished change never becomes state.

an update, and the ones that fail
import { box, untracked, update } from "@frondruntime/pinna";
import { schemaBox } from "@frondruntime/pinna-effect";
import { Schema } from "effect";

const $count = box(realm, 0);
const $age = schemaBox(realm, Schema.Int, 30);

// Only update hands out write; watchers see its writes together.
update(realm, (read, write) => {
  write($count, read($count) + 1);
  write($age, 31);
});

// A value of the wrong type, and one its schema rejects
update(realm, (_read, write) => {
  write($age, "thirty");^^^^^^^^ type error TS2345});
update(realm, (_read, write) => {
  write($age, 30.5);^^^^ throws});

// An await inside an update
update(realm, async (_read, write) => {^^^^^^^^^^^^^^^^^^^^^^^^^ type error TS2345^^^^^ throws  await save();
  write($count, 2);
});

// An update that throws is undone
try {
  update(realm, (_read, write) => {
    write($count, 5);
    throw new Error("stop");
  });
} catch {}
untracked(realm, (read) => read($count)); // 1: the write is undone

State lives in a realm.

Pinna keeps no global state: a box answers only to the realm that made it. A call from another realm, or out of its place, throws and says where the call belongs.

two realms, and calls out of place
import { box, computed, createRealm, type Read, untracked, update } from "@frondruntime/pinna";

// Each test or request creates its own realm, and a box answers only to the one that made it.
const app = createRealm({ name: "app" });
const quotes = createRealm({ name: "quotes" });
const $count = box(app, 0);
const $price = box(quotes, 0);

// An observable of another realm
update(app, (_read, write) => {
  write($price, 1);^^^^^^ throws});

// A read kept past its update
let kept: Read | undefined;
update(app, (read) => {
  kept = read;
});
setTimeout(() => kept?.($count));^^^^^^^^^^^^^^ throws
// An update inside a computed value
const $double = computed(app, (read) => {
  update(app, (_read, write) => {^^^^^^ throws    write($count, 1);
  });
  return read($count) * 2;
});
untracked(app, (read) => read($double));
api

The API, in one sample.

A state manager decides where state lives, then does five jobs: create it, read it, write it, observe it, and start work while something reads it. The sample uses @frondruntime/pinna, which needs no Effect.

Boxes, computed values, and updates
  • pinna

    The realm, boxes, computed values, collections, models, updates, and watchers. It needs no Effect.

    createRealmatomboxcollectiononRowChangecomputedcomputedFunctionModelupdateobservewatchautorunonObserveduntrackedisTrackingreconcileinspect

    pinna/src/index.ts
  • pinna-react

    The provider that hands components the realm, and the hooks that read it.

    RealmProvideruseRealmuseSelectuseValueuseValues

    pinna-react/src/index.ts
  • pinna-effect

    Models on Effect Schema, and Effect programs that stop with their scope. It re-exports every name of pinna.

    schemaBoxSchemaModelBoxFieldCollectionFieldschemaCollectionFromContextdecodereconcileSchemaRealmServicewatchScopedchangesobserveScopedfromStreamwhileObserved

    pinna-effect/src/index.ts
the five jobs
import {
  autorun,
  box,
  computed,
  createRealm,
  onObserved,
  update,
  watch,
} from "@frondruntime/pinna";
import { useValue } from "@frondruntime/pinna-react";

// Realm: where state lives. A test or a request creates its own.
const realm = createRealm();

// Create: a box holds state, a computed value derives from it.
const $count = box(realm, 0);
const $double = computed(realm, (read) => read($count) * 2);

// Read: a component reads through a hook. No hook, no read.
function Counter() {
  const double = useValue($double);
  return (
    <button type="button" onClick={increment}>
      {double}
    </button>
  );
}

// Write: write exists only inside update.
function increment() {
  update(realm, (read, write) => write($count, read($count) + 1));
}

// Observe: watch runs when the value it selects changes,
// autorun when anything it read changes. Each returns its stop.
const stop = watch(
  realm,
  (read) => read($double),
  (double) => {
    document.title = String(double);
  },
);
const stopLog = autorun(realm, (read) => void console.log(read($double)));

// Start work: when the first observer arrives,
// and return what stops it when the last one leaves.
// This one counts up each second while something reads $count.
onObserved($count, () => {
  const timer = setInterval(increment, 1000);
  return () => clearInterval(timer);
});

Pinna exports 36 names: pinna 17, pinna-react 5, and pinna-effect 14 of its own, plus all of pinna.

react

In React.

Components read through hooks, and no component is wrapped. Each feature below works with plain hooks and has a test.

  • React Compiler

    Components compiled with babel-plugin-react-compiler stay current, even one that hands its model to a helper. Reads live inside hooks, so the compiler is free to memoize the rest.

    compiler.test.tsx
  • Strict Mode

    Hooks subscribe through useSyncExternalStore. Strict Mode renders and mounts twice, and leaves no extra subscription behind: work started for the first observer stops after the last one.

    react.test.tsx
  • Server rendering

    Each request creates its own realm and hands it to RealmProvider. A server render reads values and observes nothing.

    react.test.tsx
a provider, a hook read, and a write from a handler
import { type Realm } from "@frondruntime/pinna";
import { RealmProvider, useValue } from "@frondruntime/pinna-react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { Todo } from "./todo.tsx";

// Plain components, no wrapper: a hook reads, and React Compiler memoizes the rest.
function TodoRow({ todo }: { readonly todo: Todo }) {
  const label = useValue(todo.$label);
  // A write is a model method, called from a handler like any other.
  return (
    <li>
      <button type="button" onClick={() => todo.toggle()}>
        {label}
      </button>
    </li>
  );
}

// TodoList is a model whose $todos is a collection of todos.
function TodoListView({ list }: { readonly list: TodoList }) {
  const todos = useValue(list.$todos.rows); // the collection's rows, in order
  return (
    <ul>
      {todos.map((todo) => (
        <TodoRow key={todo.id} todo={todo} />
      ))}
    </ul>
  );
}

// The provider hands down a realm: a server request or a test creates its own.
function mount(container: HTMLElement, realm: Realm, list: TodoList) {
  createRoot(container).render(
    <StrictMode>
      <RealmProvider realm={realm}>
        <TodoListView list={list} />
      </RealmProvider>
    </StrictMode>,
  );
}
effect

With Effect.

@frondruntime/pinna-effect puts Pinna on Effect Schema and adds programs that stop with their scope.

Pinna for Effect
  • A model is a SchemaModel.

    An Effect Schema.Class whose $ fields are boxes: it decodes server data, checks every write, and encodes back.

    mix.test.ts
  • The realm is a service.

    decode hands the realm to what it makes as RealmService, and programs read the same service.

    effect.test.ts
  • Programs stop with their scope.

    watchScoped runs an effect on each change, fromStream turns a stream into a value, and both stop when their scope closes.

    effect.test.ts
a model, a checked write, and a program
import {
  BoxField,
  createRealm,
  decode,
  RealmService,
  SchemaModel,
  update,
  watchScoped,
} from "@frondruntime/pinna-effect";
import { Effect, Layer, Schema } from "effect";

// One class decodes server data, checks every write to its box fields, and encodes back.
class Order extends SchemaModel<Order>("Order")({
  id: Schema.String,
  $quantity: BoxField(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
}) {}

const realm = createRealm();
const order = decode(realm, Order)({ id: "7", quantity: 2 });
Schema.encodeSync(Order)(order); // { id: "7", quantity: 2 }

// A value the schema refuses throws to the caller, with the Schema.SchemaError as its
// cause, and the update is undone.
try {
  update(realm, (_read, write) => {
    write(order.$quantity, -1);
  });
} catch (error) {
  console.error(error);
}

// A program stops with its scope: this one saves each change until the fiber is interrupted.
const save = watchScoped(
  realm,
  (read) => read(order.$quantity),
  (quantity) => saveQuantity(order.id, quantity),
);
const fiber = Effect.runFork(
  save.pipe(
    Effect.andThen(Effect.never),
    Effect.scoped,
    Effect.provide(Layer.succeed(RealmService, realm)),
  ),
);
conformance

Conformance.

Every suite runs in bun run test, and a gap that opens or closes fails the run.

reactive-framework-test-suite

161 cases, one square each, in suite order. reactive-framework-test-suite 0.2.0, MIT, Johnson Chu; shared-suite.

Pinna160 pass, 1 differs

MobX 7.1.7128 pass, 14 differ, 19 skip

alien-signals 3.2.1161 pass

  • pass
  • differs from the suite
  • skip

Hover or tap a square for its case.

Pinna differs on case #154, which expects a batch that throws to keep its writes: an update that throws is undone.

29 probes record which valid design a library takes: Pinna answers every one. The design notes list each answer.

hermes

Measurements.

Speed and memory for Pinna, alien-signals, Legend State, and MobX: in a React Native app on iOS, with the web and Android not measured yet, and for the graph alone on Bun, Node, and Hermes.

How it is measured

Lower is better. Each cell is colored against the best figure in its row on the same runtime.

  • best, or within 5% of it
  • within 1.5×
  • within 3×
  • within 10×
  • within 100×
  • within 1,000×
  • more than 1,000×, or stack overflow

Hover a cell for its ratio. A dash is not measured.

In a React Native app

Speed ms in the store

In a React Native app, speed: Pinna, alien-signals, Legend State, and MobX on Web, iOS, Android
ScenarioPinnaalien-signalsLegend State (beta)MobX
WebiOSAndroidWebiOSAndroidWebiOSAndroidWebiOSAndroid
Load 10,000 rows—51——27——166——238—
Merge a refetch into them—252——229——332——285—
Replace them all—56——30——292——249—
Insert 100 rows—14——13——31——2.7—
Remove 100 rows—15——20——43——11—
60 ticks of 50 price changes—28——25——232——42—

Memory MB

In a React Native app, memory: Pinna, alien-signals, Legend State, and MobX on Web, iOS, Android
ScenarioPinnaalien-signalsLegend State (beta)MobX
WebiOSAndroidWebiOSAndroidWebiOSAndroidWebiOSAndroid
Allocated by the load—8.5——15.4——29.1——115.9—
Garbage collections during the load collections—3——4——8——30—
Allocated by the 60 ticks—0.9——0.9——31.5——2.2—
Kept for the rows—43.5——42.3——45.9——51.9—

The graph alone

Speed ms

The graph alone, speed: Pinna, alien-signals, Legend State, and MobX on Bun, Node, Hermes
ScenarioPinnaalien-signalsLegend State (beta)MobX
BunNodeHermesBunNodeHermesBunNodeHermesBunNodeHermes
Deep chain4.014.4675.62.763.5642257overflowoverflow17.815.1204
Fan-out8.418.441405.915.851032692421,83628.527.8507
Diamond6.265.83924.974.5357.42272191,58515.814230
Conditional reads21.825.941117.716.92646215463,4166662.61,164
Make and dispose2.042.2724.41.090.9613.146.869.829113.621.571.1
Write 1,000 sources6.796.921145.294.2985.810896.571018.618.4291
Bursty fan-out9.298.8514160.790.34887291,0814,19228.127.3494
Increment ×100,00012.115.12239.136.931473563171,94838.138579
One write among 10,0001.170.62.610.890.421.816.110.224.91.941.376.57

Memory allocated by one graph run KB

The graph alone, memory allocated by one graph run: Pinna, alien-signals, Legend State, and MobX on Bun, Node, Hermes
ScenarioPinnaalien-signalsLegend State (beta)MobX
BunNodeHermesBunNodeHermesBunNodeHermesBunNodeHermes
Deep chain—1014—3,9257,845—overflowoverflow—39,24031,353
Fan-out—1014—147,845—394,184642,827—84,89088,380
Diamond—1014—187,852—373,314652,397—40,58332,979
Conditional reads—7,98910,959—7,83642,089—898,5391,462,496—176,559178,300
Make and dispose—11,08412,746—7,39011,652—118,060156,914—48,74331,116
Write 1,000 sources—1014—1017,983—244,663389,152—51,47164,935
Bursty fan-out—34214—1648,850—878,9871,753,886—76,33388,380
Increment ×100,000—9,57810,941—14,50136,722—742,6931,145,927—125,035128,911
One write among 10,000—178191—217448—8,68711,987—1,1631,372
How these were measured

Where they ran

The app on 2026-11-16, the graph on 2026-11-18.

The app
apps/rn-bench, a release build on Hermes on the iPhone 17 Pro simulator. 10,000 rows, full mode. Each figure is the median of three rounds.
The graph on Node and Hermes
pinna-bench's rough tier on Node 26.13.1 and on Hermes 260318099.0.5, the one React Native 0.88.1 ships, from the command line. One launch a cell, a process of its own that makes the library's instance once; a figure is the median of that launch's samples. The machine's load average was 1.6 to 3.7. Every library's watchers run the same effect, made once per process, which counts its calls, and every bundle is a production build.
The graph on Bun
bench:graph on Bun 1.4.4, the median of 9 runs, each library in a process of its own with NODE_ENV set to production.

What a figure counts

App speed
The synchronous write. Pinna and alien-signals rerun their readers inside it; MobX and Legend State rerun theirs in the render that follows, which is not timed.
Parsing
Left out. Every store takes plain values: JSON.parse and the conversion from wire JSON, 760 to 845 ms of each bulk write, are timed apart.
App memory
Hermes's own counters, the median of the three rounds.
  • Allocated: bytes allocated during the store's write alone, garbage included.
  • Kept: allocated bytes after two forced full garbage collections with the 10,000 rows loaded, minus the same with the store empty, read on a fresh screen after every timed scenario.
Graph memory
Kilobytes allocated by one run of each scenario, the median of the runs, from the same pinna-bench run as the speed figures.
  • Node: V8's total allocated bytes, in a launch of its own with --no-inline-new, 15 runs after 10 of warm-up.
  • Hermes: its count of allocated bytes, in the timed launches.
  • Bun: not measured.

The same for every library

One shape
Every store in the app keeps the same three fields of a row reactive, and all four share one list, one set of views, and one merge rule. The merge is mostly a comparison all four share.
One build
babel-preset-expo's defaults, tuned for none of them, and no store's rows extend a class. Under those defaults, making an instance of a class that extends another costs about 2.6 KB and 2.8 µs in Babel's callSuper helper.
Noise
Insert and remove vary up to 3× between rounds.

Each library

Pinna
Plain boxes, which check nothing, held in plain objects rather than Model subclasses. Its tick looks rows up through read.row, which makes nothing per key where nothing tracks.
alien-signals 3.2.1
In the app, through a React hook written for this app.
Legend State 3.0.0-beta.48
A beta. In the app, loaded in one set; its ticks are not profiled. In the graph, its deep chain overflows the stack on Node and Hermes.
MobX 7.1.7
It makes an ObservableValue, which extends Atom, per observable field, so it pays Babel's helper inside its own code: the app's load and replace take about 80 ms more, and the load 60 MB more, than MobX 6.15.3's ES5 build did. On Hermes from the command line, without Babel, 7.1.7 is the faster of the two.

Reproducing

Node and Hermes
bun run bench --tier publishIn packages/pinna-bench. Hermes needs a hermes-ios release, given with --hermes or PINNA_HERMES.
Bun
bun run --cwd packages/pinna bench:graph
The app
bun run --cwd apps/rn-bench iosthenbun run --cwd apps/rn-bench bench --mode full