@preact/signals
2.11.4 · 27 Oct 2026MIT4.7M / weekRepositoryHomepagenpmAtom feed
2.11.4 is the newest release of 2.x.
In short
1 new1 fixed1 internal
Release note
Minor Changes
Add
useModelhook for using Models in componentsThe new
useModelhook provides a convenient way to use Models (created withcreateModel) within React and Preact components. It handles:Creating the model instance lazily on first render
Maintaining the same instance across re-renders
Automatically disposing the model when the component unmounts
import { createModel, signal } from "@preact/signals-core"; import { useModel } from "@preact/signals-react"; // or "@preact/signals" const CountModel = createModel(() => ({ count: signal(0), increment() { this.count.value++; }, })); function Counter() { const model = useModel(CountModel); return <button onClick={() => model.increment()}>{model.count}</button>; }For models that require constructor arguments, wrap in a factory function:
const CountModel = createModel((initialCount: number) => ({ count: signal(initialCount), })); function Counter() { const model = useModel(() => new CountModel(5)); return <div>{model.count}</div>; }
Patch Changes
Revert #728 - this might entail work in prefresh but currently the presence of
uesStatemakes every sCU bail
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.