This guide walks you through installingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/christianbaroni/stores/llms.txt
Use this file to discover all available pages before exploring further.
@storesjs/stores and composing a reactive store graph — a base store for settings, a query store for remote account data, and a derived store that combines them both — then consuming the result in a React component.
Install @storesjs/stores
Add React ≥18 is an optional peer dependency for the React build. React Native ≥0.69 is required for the native build. See Installation for full peer dependency details.
@storesjs/stores to your project with your preferred package manager:Create a base store
A base store defines synchronous local state along with methods for updating it. Create Read and update state outside React using the store object directly:
settingsStore.ts to hold user preferences:Create a derived store
Derived stores compute values from other stores. The Every property accessed through
$ accessor tracks dependencies at runtime — whenever a tracked store changes, the derived store re-computes automatically:$(settingsStore) — currency and locale — is tracked. If either changes, currencyFormatterStore produces a new Intl.NumberFormat instance.Create a query store
Query stores fetch, cache, and revalidate async data. Their The
params values can themselves be reactive — when a param changes, the store refetches:staleTime option controls how long cached data is considered fresh before a re-fetch is triggered. time.minutes(10) is a built-in helper that converts to milliseconds.Access the fetched data via getData():Composed Example
Here is the full composed graph from the README — a derived store that formats an account balance using live settings, and a component that renders the result:AccountSummary subscribes to accountBalanceStore, which in turn tracks accountStore and currencyFormatterStore. currencyFormatterStore tracks settingsStore. The entire chain reacts automatically — change the currency in settings and the displayed balance re-formats without any manual wiring.
Global Configuration
Before creating any stores, you can callconfigureStores() to set global defaults such as a custom storage backend, storage key prefix, or default query options:
configureStores() must be called before any store is created. Calling it after the first store creation will throw in development. See the configuration guide for all available options.