Overview
useStore(store) registers the current host for re-render whenever store notifies. It accepts anything with __subscribe (Mates atoms, setters, actions) or subscribe (Zustand, Redux, custom).
It returns the same store for chaining. Cleanup is automatic on unmount. Prefer reading Mates atoms inside the template when you only need Mates reactivity — use useStore to bridge external stores or to opt a host into updates without relying solely on template tracking.
vs template atom reads
|
Approach
|
Deps
|
Prefer when
|
|---|---|---|
count() in template
| auto-track | Default for Mates atoms inside the rendering component. |
useStore(store)
| manual host sub | Third-party stores, or ensure a host re-renders on notify. |
Subscribe to a shared atom
Display and App both call useStore(shared) so they stay subscribed to the module-level atom.
External subscribe()-shaped store
useStore works with Redux/Zustand-style { subscribe }. The playground uses a tiny custom store with the same shape.