Use this file to discover all available pages before exploring further.
@storesjs/stores ships a vanilla build that exports all three store creators — createBaseStore, createDerivedStore, and createQueryStore — but strips the React hooks entirely. The same import path works in both builds; your bundler selects the right entry point via the vanilla package export condition. The result is a fully reactive store graph that works in Node.js scripts, browser vanilla JS, CLI tools, or any environment where React is not present.
In the React build, stores are callable hooks — you can write settingsStore(s => s.currency) inside a component. In vanilla mode the hook call signature is not available. Stores are plain store objects and you interact with them through their API methods directly.
// Read current stateconst state = store.getState();// Write state — accepts a partial update or a full replacementstore.setState({ currency: 'EUR' }); // mergestore.setState({ ...state, currency: 'EUR' }, true); // replace// Subscribe to state changesconst unsubscribe = store.subscribe( state => state.currency, // selector (current, previous) => { console.log('currency changed', current, previous); }, { equalityFn: Object.is, fireImmediately: false });// Unsubscribe when doneunsubscribe();// Read the initial state as returned by the creator functionconst initial = store.getInitialState();
Derived stores expose getState(), subscribe(), and destroy(). They do not expose setState or getInitialState — those methods exist on the type but throw if called.
import { createDerivedStore } from '@storesjs/stores';const formattedBalanceStore = createDerivedStore($ => { const { currency } = $(settingsStore); const balance = $(accountStore).getData()?.balance ?? 0; return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(balance);});// Read the derived valueconsole.log(formattedBalanceStore.getState());// Subscribe to changesconst unsubscribe = formattedBalanceStore.subscribe( s => s, formatted => console.log('balance display:', formatted));// Flush pending updates (only relevant for debounced derived stores)formattedBalanceStore.flushUpdates();// Tear down when no longer neededformattedBalanceStore.destroy();
React hooks — useListen and useStableValue — are not exported from the vanilla build. They are exclusive to the React build (index.ts). The vanilla entry (index.vanilla.ts) re-exports everything from index.shared.ts, which contains only the store creators, configuration utilities, and type exports.