@nexa/reactivity
No Virtual DOM — signals that notify whoever reads them, directly. For writing an island by hand.
state() — Signal
import { state } from "@nexa/reactivity";
const count = state(0);
count.value = 1; // dispara efectos suscriptos.value reads and subscribes; .peek() reads without subscribing. Writing .value fires the effects that read it, batched by microtask.
computed()
import { computed } from "@nexa/reactivity";
const doubled = computed(() => count.value * 2);
doubled.value; // sin setterA ReadonlySignal that recalculates on its own. Chaining computeds works, at a real cost: each hop is one more microtask round-trip.
effect()
import { effect } from "@nexa/reactivity";
const stop = effect(() => {
console.log(count.value);
});
stop();Runs right away, and again every time something it read changes. Returns a function to turn it off.
watch()
import { watch } from "@nexa/reactivity";
watch(
() => count.value,
(nuevo, viejo) => console.log(nuevo, viejo),
);Like effect, but does NOT run when created — only on later changes. Receives the new and the old value.
bindText()
import { bindText } from "@nexa/reactivity";
bindText(node, () => count.value);What the compiler automatically generates for {data.x} in a page's body — not something you'd normally write by hand.
mountComponent() — islands only
import { mountComponent, type Component } from "@nexa/reactivity";
const List: Component<{ labels: string[] }> = (el, props, ctx) => {
for (const label of props.labels) {
const li = document.createElement("li");
el.appendChild(li);
ctx.mount(Item, li, { label });
}
};Doesn't apply to Nexa Core pages. Component<P>, typed props, and chained cleanup — no Virtual DOM.