@preact/signals-react
3.12.0 · 4 Aug 2026MIT732k / weekRepositoryHomepagenpmAtom feed
Your version
3.12.0 is the newest release of 3.x.
In short
1 new1 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>; }
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.