Skip to main content

Documentation 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.

configureStores establishes global defaults that apply to every store created in your application. It must be called before any store is created — typically at the top of your app’s entry point or initialization module. Any options you do not set fall back to sensible environment-specific defaults.

Signature

function configureStores(config: Partial<StoresConfig>): void

StoresConfig fields

storage
SyncStorageInterface | AsyncStorageInterface
The storage backend used by all persisted stores. Defaults to localStorage in browser environments and MMKV in React Native. Supply a custom adapter to swap in any other key-value storage.
syncEngine
SyncEngine
The sync engine used for cross-client state synchronization. Defaults to a BroadcastChannel-based cross-tab engine in browsers and a no-op engine in all other environments. Replace this with a WebSocket or chrome.storage engine for multi-device sync.
storageKeyPrefix
string
default:"'stores:'"
A prefix prepended to every storage key generated by the default storage adapter. Should include a delimiter such as a colon, e.g. 'myapp:'. Only applies when using the built-in storage adapter — custom adapters manage their own key scheme.
logger
Logger
A custom logger for framework debug output. Defaults to a no-op logger in production builds. Provide { debug, error, info, warn } to route framework messages through your own logging infrastructure.
queryStoreDefaults
QueryStoreDefaults
Default configuration values applied to every query store. Individual stores can override any of these values in their own config.

Example

import { configureStores, time } from '@storesjs/stores';

configureStores({
  storageKeyPrefix: 'myapp:',
  queryStoreDefaults: {
    staleTime: time.minutes(5),
    maxRetries: 3,
  },
  logger: {
    debug: console.debug,
    error: console.error,
    info: console.info,
    warn: console.warn,
  },
});
Calling configureStores after any store has been created throws an error in development:
[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.
Always invoke configureStores at the top of your entry point, before any createBaseStore, createQueryStore, or other store creator call executes.

Build docs developers (and LLMs) love