Delete useMemo, useCallback and every dependency array.
Signals know who reads them, so derived values and effects keep themselves up to date and a write touches only what depends on it. It is the engine under every Pyreon app, with no dependencies, and it runs on its own in Node, Bun, a worker or a script.
bun add @pyreon/reactivity - dependencies
- noneOne optional peer, used only by the native compiler.
- effect propagation
- 2.0–2.1× Preact SignalsV8, two runs, synthetic, author-run.
- dependency arrays
- 0Dependencies are tracked when a signal is read.
- native
- signal, computed, effect and batch lower to iOS and AndroidNative targets are experimental.
- 2.1× faster effect propagation than Preact Signals (1,407 vs 2,874 ns, 100 effects)BENCHMARKS.md 2026-11-05 §8, V8, final pass, two runs (2.04–2.13×)
- 1.95× faster batching of 50 signal writes than Preact Signals (456 vs 888 ns)BENCHMARKS.md 2026-11-05 §8, V8, two runs (1.94–1.95×)
- 2 of 10,000 row effects re-run when the selection moves, with
createSelectorrun on main: .scratch/core/parent/r2.ts prints 2
synthetic · author-run · M3 Max · record of 2026-11-05
Every result, including where we lose →Less to write, less to get wrong.
Nothing to list
A computed or effect subscribes to exactly the signals it read on its last run. When a branch stops reading a signal, the dependency is dropped, so there is no array to keep in sync and no stale closure to chase.
One write, one update
batch()groups writes and runs each effect once with the final values. A diamond (afeeding two computeds that feed one effect) never shows a half-updated state.Cheap where lists are big
A signal with one subscriber keeps it in an inline slot and allocates no
Set.createSelectorre-runs 2 rows when a selection moves, not 10,000.Ask why it ran
Call
why()before a write and the console names each signal that changed:[pyreon:why] "first": "Ada" → "Grace" (1 subscriber).inspectSignalandgetReactiveTracego deeper.
The same cart, with and without dependency arrays.
Three dependency arrays to keep right, and the whole function runs again on every click.
import { useState, useMemo, useEffect, useCallback } from 'react'
export function Cart({ price }: { price: number }) {
const [qty, setQty] = useState(1)
const total = useMemo(() => price * qty, [price, qty])
const add = useCallback(() => setQty((n) => n + 1), [])
useEffect(() => {
document.title = `Total: ${total}`
}, [total])
return (
<button onClick={add}>
{qty} × {price} = {total}
</button>
)
}No arrays. The function runs once; a click updates two text nodes and the title.
import { signal, computed, effect } from '@pyreon/reactivity'
export function Cart(props: { price: number }) {
const qty = signal(1)
const total = computed(() => props.price * qty())
effect(() => {
document.title = `Total: ${total()}`
})
return (
<button onClick={() => qty.update((n) => n + 1)}>
{qty()} × {props.price} = {total()}
</button>
)
}What turns signals into pixels.
JSX, components, context, For, Show and lifecycle.
Decides at build time which expressions are live.
Fine-grained DOM updates and hydration.
Streaming SSR to strings and streams.
A bounded cache used across the engine.
Coming from React useState, React useMemo or React useEffect?
State you can read right after you write it
const [count, setCount] = useState(0)
function addTwo() {
setCount(count + 1)
setCount(count + 1) // still the old count: adds 1, not 2
}count() reads, count.set(v) writes, count.update(fn) derives. Calling count(5) only reads, so writes are always .set.
const count = signal(0)
function addTwo() {
count.set(count() + 1)
count.set(count() + 1) // reads the new value: adds 2
}Derived values without a dependency list
const total = useMemo(() => price * qty, [price, qty])A computed is lazy and cached: it recomputes only when read after a dependency changed. If it returns a new object each time, pass { equals } so readers skip identical results.
const total = computed(() => price() * qty())Side effects that re-run on their own
useEffect(() => {
const id = setInterval(tick, delay)
return () => clearInterval(id)
}, [delay])The effect re-runs when delay changes, cleaning up first. Effects run synchronously after a write (or once at the end of a batch), and one created inside a component is disposed with it.
effect(() => {
const id = setInterval(tick, delay())
return () => clearInterval(id)
})Write signals, count the runs.
Two signals, one computed, one effect. Batching groups writes so the effect runs once.
- price = signal(100)0
- qty = signal(2)0
- total = computed · 2001
- effect runs1
Numbers count writes and runs. They are read from the signals themselves.
Fastest where an update spends its time: propagation.
Pyreon wins the work a real update runs through: effect propagation, batching and the computed diamond. It loses raw signal creation (4.8×), deep unobserved chains (1.42×) and wide fan-out (3–4%), and those rows stay in the table.
- effect propagation (100)1,407 ns2,874 nswin2.04–2.13× vs Preact
- batch 50 signals456 ns888 nswin1.94–1.95× vs Preact
- computed diamond (100 updates)4,424 ns5,761 nswin1.30–1.31× vs Preact
- wide fan-out (1 → 100 effects)1,651 ns1,602 nslossPreact 1.03–1.04× ahead
- deep chain (depth 50)107,237 ns75,639 nslossPreact 1.42–1.43× ahead
- signal create + read + write63 ns13 nslossPreact 4.8× ahead
- create 10,000 rows (vs React 19)72.64 ms192.01 mssplit2.6× vs React 19; vs the fastest rivals a split: tie in one run, 1.02× in the other
- clear 1,000 rows130 µs145 µswin1.11–1.12× vs Vue 3.6 Vapor, the fastest rival
Every reactive primitive you reach for.
- signal with
set,update,peekandtriggerfor values mutated in place - computed lazy and cached, with optional
equals - linkednext release a writable value that resets when its source changes
- effect and onCleanup, plus
renderEffectfor the cheapest DOM bindings - batch and nextTick: nested batches flush once, at the outermost exit
- watch for an explicit source and a
(next, prev)callback - createSelector for O(1) selection in long lists
- createStore and reconcile for deep reactive objects and patching them from API responses
- createResource for async data with loading, error and stale-response handling
- why, inspectSignal and getReactiveTrace to see what changed and what ran
Things to build with it.
A plain selected() === id check in every row re-runs all 10,000 rows on each click. createSelector keeps a bucket per value and notifies only the row that lost the selection and the one that gained it.
import { signal, effect, createSelector } from '@pyreon/reactivity'
const selected = signal(-1)
const isSelected = createSelector(() => selected())
let runs = 0
for (let id = 0; id < 10_000; id++) {
effect(() => {
isSelected(id) // in a real row: class={isSelected(id) ? 'row on' : 'row'}
runs++
})
}
runs = 0
selected.set(42)
selected.set(7)
console.log(runs) // 3: one row for the first pick, then two for the movecreateResource refetches when its source changes and ignores any response that arrives after a newer request started, so a slow reply to "p" can't overwrite the answer to "py".
import { signal, createResource } from '@pyreon/reactivity'
const query = signal('')
const results = createResource(
() => query(),
(q) => fetch(`/api/search?q=${encodeURIComponent(q)}`).then((r) => r.json()),
)
query.set('p') // slow request
query.set('py') // fast request
// results.data() ends up holding the answer to 'py', whichever reply lands last
// results.loading() and results.error() are signals toolinked() follows a source like a computed but can be overwritten like a signal. Keep the user's pick while it is still offered; fall back to the first option when it is not.
import { signal, linked } from '@pyreon/reactivity'
const sizes = signal(['S', 'M', 'L'])
const size = linked(sizes, (opts, prev): string =>
prev && opts.includes(prev.value) ? prev.value : (opts[0] ?? ''),
)
size.set('L')
console.log(size()) // 'L'
sizes.set(['M', 'L', 'XL'])
console.log(size()) // 'L' (still offered, kept)
sizes.set(['XS', 'S'])
console.log(size()) // 'XS' (gone, reset)Grouped the way you use them.
Every export has a reference page with its signature, an example and the mistakes people make with it.
- signal
- computed
- effect
- renderEffect
- batch
- nextTick
- untrack
- watch
- cell
- createStore
- reconcile
- shallowReactive
- markRaw
- isStore
- createResource
- createSelector
- wrapSignal
- effectScope
- onCleanup
- onScopeDispose
- getCurrentScope
- why
- inspectSignal
- onSignalUpdate
- getReactiveTrace
- getReactiveGraph
- describeReactiveGraph
- setErrorHandler
- linked
Good to know before you start.
Mutating in place needs trigger()
Signals compare with Object.is, so set(sameObject) does nothing. Update immutably, or mutate and call trigger().
Read inside a tracking scope
A signal read in a plain function body subscribes nothing. Read it in an effect, a computed or JSX.
A new object every time means a notify every time
A computed that returns a fresh object or array notifies on each recompute. Pass equals when readers should skip identical results.
Cheap to update, not the cheapest to create
Creating a signal costs about 5× what Preact Signals does (63 vs 13 ns on V8). Create them once, not inside hot loops.
What people ask first.
Can I use it without the rest of Pyreon?
Yes. It has no dependencies and no DOM code: bun add @pyreon/reactivity and use it in Node, Bun, a worker or a CLI. Pyreon's components, router, forms, queries and stores all build on it.
Are effects synchronous?
Yes. A write runs the effects that depend on it before set() returns, unless you are inside batch(), which runs them once at the end. await nextTick() waits for the DOM after a write.
How does it compare with Preact Signals and Solid?
Same model, measured: about 2.1× Preact on effect propagation, 1.95× on batching and 1.3× on a computed diamond (V8, two runs). It loses signal creation (4.8×), deep unobserved chains (1.42×) and wide fan-out by 1.03×. Solid is behind on every row except creation.
Why count() and not count.value?
A signal is a function, so reading it is a call and passing it around passes the live value. There are no proxies unless you ask for one with createStore.
Does it work in the iOS and Android builds?
Yes, on the experimental native targets: signal and computed compile to SwiftUI and Compose state through PMTC, effect re-runs when what it read changes, and batch lowers too. linked(), coming in the next release, has no native lowering yet, and the compiler warns by name when it meets one.
Your components stop re-rendering. You stop wondering why they did.
bun add @pyreon/reactivity