Skip to main content

Reference

useStore

A Solid.js primitive that subscribes to a TanStack Store atom and returns a signal accessor. The signal 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

Accessor<TSelected>
A Solid.js signal accessor function that returns the selected state value.

Usage

Basic Usage

Selecting Multiple Values

Custom Equality Function

Using Entire State

With Derived State

With Show Component

Notes

  • Returns a Solid.js signal accessor - call it as a function to get the value
  • Uses createSignal internally for fine-grained reactivity
  • Automatically cleans up subscriptions using onCleanup
  • Defaults to shallow equality comparison for optimal performance
  • The selector is evaluated immediately on creation and on each update
  • Integrates seamlessly with Solid’s reactive primitives like createMemo, createEffect, etc.