Reference
useStore
current property. The value will update when the selected state changes according to the equality function.
Atom<TState> | ReadonlyAtom<TState>
The store atom to subscribe to.
(state: TState) => TSelected
default:"(d) => d"
Optional function that selects a slice of state from the atom. Defaults to returning the entire state.
UseStoreOptions<TSelected>
Optional configuration object.
Returns
{ readonly current: TSelected }
A reactive object with a readonly
current property containing the selected state value.Usage
Basic Usage
Selecting Multiple Values
Custom Equality Function
Using Entire State
With Conditional Rendering
With Each Blocks
Derived Values
Selecting Array Slices
Notes
- Built for Svelte 5 using the new runes system (
$state,$effect) - Returns an object with a readonly
currentproperty - Uses
$staterune internally for reactivity - Automatically cleans up subscriptions using
$effectcleanup - Defaults to
shallowequality comparison - Access the value via
.currentproperty - Compatible with Svelte’s reactive declarations and derived values
- Works seamlessly with
{#if},{#each}, and other Svelte control flow