This is the full developer documentation for @lolmaus/config-store
# @lolmaus/Config-store
Manage frontend settings transparently!
A frontend library to store an arbitrary config (user settings) with strict typing, Zod validation, automated schema migrations, adapters to persist to localStorage or backend
## Features
- **Universal Config**
Store user settings feature flags or any persistent client-state in a centralized JSON-like
structure.
- **Zod-Powered**
The config is defined as a [Zod](https://zod.dev) schema, providing strict TypeScript inference
across your codebase. Each setting can be anything from a `boolean` to a complex nested object.
The Zod schema also provides defaults for each value.
- **Migrations**
As your schema changes, define migration functions to automatically update a user's config to
conform to the new schema. This process is transparent to the consuming app.{' '}
- **Flexible Adapters**
Ships with a simple `LocalStorageAdapter` and a versatile `AsyncAdapter` (e. g. for REST APIs).
You can easily define custom adapters for other protocols (e.g., WebSocket, IndexedDB).
- **Concurrency Control**
The `AsyncAdapter` provides three strategies for parallel writes:
- **abort**: Cancels previous pending requests (default, relies on AbortController).
- **optimistic concurrency control**: On top of the **abort** strategy, your backend can emit
`409 Conflict` on an attempt to overwrite an newer config version with a newer one.
- **sequential**: Waits for each update to finish before processing the next one. Updates pile
up in a queue. Useful for legacy backends, at the cost of UX.
- **Framework-agnostic**
The core can be used with vanilla JS or in any framework.
The following framework integrations are available:
- **React**: Provides hooks like `useConfig` and `useUpdateConfig`. Makes sure your components rerender only when the relevant individual settings change. Unrelated changes to the config will not cause rerenders.
Support for other frameworks is not planned, but contributions are very welcome.
# Installation
## Core package
Make sure you have [Zod 4](https://zod.dev) installed.
Install the `@config-store/core` package using your preferred npm-based package manager:
```sh
npm add @config-store/core
pnpm add @config-store/core
yarn add @config-store/core
bun add @config-store/core
```
⠀
## In a React app
Additionally, install `@config-store/react`.
Make sure you're on React 18+.
⠀
## Use with other frameworks
Support for other frameworks is not planned, but contributions are very welcome.
Meanwhile, you can integrate the `ConfigManger` by hand.
⠀
## Version compatibility
If using previous versions of packages, mind version compatibility table:
| Branch | @config-store/core | @config-store/react |
| ---------------- | ------------------ | ------------------- |
| `gen0` (current) | >= 1.0.0 | >= 1.0.0 |
# Schema Defintion Rules
`@config-store` relies on [Zod](https://zod.dev) schema to provide default values.
This means that the schema must be able to accept an empty initial value (e. g. `null` or `undefined`) and parse it into a default config.
Here's how to achieve that, assuming you store settings in an object.
## Handling undefined initial value
If your adapter receives `undefined` as an empty initial value, then you must attach [.prefault({})](https://zod.dev/api?id=prefaults) to your outmost `z.object()`.
```ts ".prefault({})"
const MySettingsSchema = z.object().prefault({}); // Converts initial `undefined` value to `{}`
MySettingsSchema.parse(undefined); // => {}
```
## Handling null initial value
If your adapter receives `null` as an empty initial value, then you must wrap the entire schema with [.preprocess()](https://zod.dev/api#preprocess), converting `null` into an empty object `{}`.
Also handles `undefined`!
```ts "z.preprocess(" "(config: unknown) => config ?? {}," "null"
const MySettingsSchema = z.preprocess(
(config: unknown) => config ?? {},
z.object() // You don't need `.prefault({})` on root level when using `.preprocess()`
);
MySettingsSchema.parse(null); // => {}
```
## Handling default values for properties
You must attach [.default()](https://zod.dev/api?id=defaults) to every primitive property.
```ts /(.default.+),/ "{}"
const MySettingsSchema = z.object({
menuExpanded: z.boolean().default(true),
darkTheme: z.boolean().default(false),
});
MySettingsSchema.parse({}); // => {menuExpanded: true, darkTheme: false}
```
## Handling nested objects
You must attach [.prefault({})](https://zod.dev/api?id=prefaults) to every nested object.
```ts ".prefault({})" "{}"
const MySettingsSchema =
z.object({
nestedSettings: z.object().prefault({}),
})
);
MySettingsSchema.parse({}); // => {nestedSettings: {foo: 'bar', baz: 'zomg'}}
```
## Handling everything together
Now you're ready to build your schema:
```ts /(.default.+),/ ".prefault({})" "undefined"
const MySettingsSchema = z
.object({
menuExpanded: z.boolean().default(true),
darkTheme: z.boolean().default(false),
nestedSettings: z
.object({
foo: z.string().default('bar'),
baz: z.literal(['quux', 'zomg', 'lol']).default('zomg'),
})
.prefault({}),
})
.prefault({});
MySettingsSchema.parse(undefined); // =>
/**
* {
* menuExpanded: true,
* darkTheme: false,
* nestedSettings: {
* foo: 'bar',
* baz: 'zomg'
* }
* }
*/
```
# React Quickstart
## 1. Define the manager and the schema
In e. g. `src/settings/manager.ts`, instantiate the adapter and pass it to the `ConfigManager`.
Chain `.addVersion()` to define your schema history.
```ts
import {ConfigManager, LocalStorageAdapter, type InferConfig} from '@config-store/core';
import {z} from 'zod';
// Create your adapter (or import a custom one)
const adapter = new LocalStorageAdapter({key: 'my-app-settings'});
// Initialize the manager with the adapter
export const configManager = ConfigManager
// Initialize with adapter and schema version 1
.create(adapter, {
version: 1,
schema: z
.object({
menuExpanded: z.boolean().default(true),
darkTheme: z.boolean().default(false),
})
.prefault({}),
})
// Eventually, add schema version 2 as your settings evolve
.addVersion({
version: 2,
schema: z
.object({
menuExpanded: z.boolean().default(true),
// Changed from boolean 'darkTheme' to 'theme' typed as 'light' | 'dark' | 'high-contrast'
theme: z.literal(['light', 'dark', 'high-contrast']).default('light'),
})
.prefault({}),
// Migrate uesrs from schema version 1 to 2
migration: (prev) => {
// TypeScript automatically infers 'prev' as the previous version 😙👌
return {
...prev,
// Migrate the theme setting from boolean to string
theme: prev.darkTheme ? ('dark' as const) : ('light' as const),
};
},
});
// Export the current config type
export type MySettings = InferConfig;
```
⠀
## 2. Generate typed hooks
In e. g. `src/settings/hooks.ts`, make versions of hooks `useConfig` and `useUpdateConfig` that are typed with your current config shape:
```ts
import {createHooks} from '@config-store/react';
import type {MySettings} from './manager';
export const {useConfig, useUpdateConfig, useUpdateConfigReducer} = createHooks();
```
⠀
## 3. Wrap your app with the config provider, load the config
Pass your `configManager` instance into the `manager` prop of the provider.
```tsx
import {ConfigProvider} from '@config-store/react';
import {configManager} from './settings/manager';
export const AuthenicatedPageLayout = () => {
// Fetch settings when the app is initially loaded
configManager.load();
return (
);
};
```
⠀
## 4. Read config
Use the hook `useConfig` to read config:
```tsx
import {useConfig} from 'my-app/settings/hooks';
export const PageWrapper = ({children}) => {
// Get the entire settings object
const config = useConfig();
// Pass a selector to subscribe only to specific changes (renders optimized)
const theme = useConfig((s) => s.theme);
return
{children}
;
};
```
⠀
## 5. Persist config updates
`@config-store/react` provides _three_ ways of updating the store. Pick the one that suits your case.
⚠️ If you're not using [React Compiler](https://react.dev/learn/react-compiler), make sure to tighten these examples with `useCallback` and `useMemo`.
⠀
### 5.1. Write the entire config into the store
```tsx "clickHandler" {10-14} "config"
import {useUpdateConfig} from 'my-app/settings/hooks';
export const ThemeToggler = () => {
const config = useConfig();
const {update} = useUpdateConfig();
// This is the value we're gonna write to the store
const [userInput] = useState<'light' | 'dark'>(config.theme);
const clickHandler = () =>
update({
...config,
theme: userInput,
});
return (
);
};
```
⠀
### 5.2. Update a specific value in the store with a mutator
```tsx /{(clickHandler)}/ {12-18} "config"
import {useUpdateConfig} from 'my-app/settings/hooks';
export const ThemeToggler = () => {
// Selector selects a specific property on the settings
const theme = useConfig((c) => c.theme);
// This is the value we're gonna write to the store
const [userInput] = useState<'light' | 'dark'>(theme);
const {update} = useUpdateConfig();
const clickHandler = () => {
// Pass a mutator callback into the `update`
update((config) => ({
...config,
theme: userInput,
}));
};
return (
);
};
```
⠀
### 5.3. Customize the update function with a reducer
`useUpdateConfigReducer` lets you preconfigure the `update` function to receive a narrow value.
In this example, we're setting it up to receive the theme value typed as `'light' | 'dark'`.
This lets us pass the `update` function directly into Select's `onChange`, without having to wrap `update` with a handle callback like in the previous example.
```tsx /(update)}/ {10-14} /(config),/
import {useUpdateConfigReducer} from 'my-app/settings/hooks';
export const ThemeToggler = () => {
// Selector selects a specific property on the config
const theme = useConfig((c) => c.theme);
// This is the value we're gonna write to the store
const [userInput] = useState<'light' | 'dark'>(config.theme);
// Preconfigure the update function to receive a theme value
const {update} = useUpdateConfigReducer<'light' | 'dark'>((config, theme) => ({
...config,
theme,
}));
return (
);
};
```
# LocalStorageAdapter
The local storage adapter persists the settings in localStorage. It's synchronous and instant.
You can instantiate it and pass directly to the manager:
```ts {3} /const (adapter)/ /(adapter),/
import {ConfigManager, LocalStorageAdapter} from '@config-store/core';
const adapter = new LocalStorageAdapter();
export const configManager = ConfigManager.create(adapter, {
version: 1,
schema: z.object().prefault({}),
});
```
## Customizing localStorage key
By default, the settings are saved to the `@lolmaus/config-store` localStorage entry.
To change the key, pass the `key` option:
```ts "{key: 'my-settings'}"
new LocalStorageAdapter({key: 'my-settings'});
```
# AsyncAdapter
`AsyncAdapter` is a flexible way of persisting data over network, e. g. to a REST API.
⠀
## 1. Defining the adapter
Define the adapter in a separate file `src/settings/adapter.ts` using the `create` static method:
```ts "AsyncAdapter.create"
import {AsyncAdapter, AdapterEnvelopeSchema} from '@config-store/core';
export const apiAdapter = AsyncAdapter.create({
read: async () => {
const res = await fetch('/api/settings');
if (!res.ok) throw new Error('Failed to fetch');
const json = await res.json();
// AdapterEnvelopeSchema is a Zod schema that parses the payload as `{config, metadata}`.
// Assuming server returns `{data: {config, metadata}}`
return AdapterEnvelopeSchema.parse(json?.data);
},
write: async (config, _lastCommittedConfig, metadata, signal) => {
const payload = {
config,
metadata, // e.g. {dataVersion: 1, schemaVersion: 1}
};
const res = await fetch('/api/settings', {
method: 'PUT',
body: JSON.stringify(payload),
headers: {'Content-Type': 'application/json'},
signal,
});
if (!res.ok) throw new Error('Save Failed');
// If your backend does not respond to writes with a payload, you can skip this.
const json = await res.json();
// AdapterEnvelopeSchema is a Zod schema that parses the payload as `{config, metadata}`.
// Assuming server returns `{data: {config, metadata}}`
return AdapterEnvelopeSchema.parse(json?.data);
},
});
```
Then register your adapter with the ConfigManager:
```ts
import {apiAdapter} from './adapter';
export const configManager = ConfigManager.create(adapter, {
/* Inital verison here */
});
```
⠀
## 2. Handling Concurrency (Race Conditions)
When a user modifies settings rapidly (e.g., dragging a volume slider), multiple save requests are generated. Network latency can cause these requests to arrive out of order.
The `AsyncAdapter` supports three strategies via the `concurrency` option to solve this:
⠀
### 2.1. Abort strategy — default
**Best for:** Modern backends and standard APIs.
When a new save starts, the library automatically aborts the previous pending request using the browser's `AbortController`.
- **Pros:** Prevents race conditions; reduces server load; UI feels snappy.
- **Cons:** Backend/Fetch must support `AbortSignal` (Standard `fetch` does).
```ts
new AsyncAdapter({
concurrency: 'abort', // default
write: async (config, _lastCommittedConfig, metadata, signal) => {
// Pass the signal to fetch!
await fetch('/api/settings', {
method: 'POST',
body: JSON.stringify({config, metadata}),
signal,
});
},
});
```
⠀
### 2.2. Optimistic Concurrency Control — best solution, requires backend logic
**Best for:** when you can customize backend logic.
Use the `abort` strategy for this approach, no frontend changes are necessary. The main difference happens on the backend side.
Why: HTTP requests may be processed in a different order from the order they have been initiated in. As a result, latest data may be overwritten by obsolete data. To prevent this, [Optimistic Concurrency Control](https://en.wikipedia.org/wiki/Optimistic_concurrency_control) (OCC) should be employed.
With each request, your adapter should send metadata containing a `dataVersion` number. `@config-store` automatically provides the metadata and increments the `dataVesion` on each save.
If requests come in the wrong order, the backend may process a recent request first. When it then processes an older request, the backend must check if the `dataVersion` of the request being processed is larger than `dataVersion` in the database. If it's not, the backend rejects the request with `409 Conflict` HTTP code.
The `AsyncAdapter` will ignore `409 Conflict` responses and drop corresponding save operations.
Ths strategy guarantees that older data does not overwrite newer data.
⠀
### 2.3. Sequential strategy — legacy Fallback
**Best for:** Legacy backends that do not support HTTP request cancellation and do not handle versioning.
The library waits for Request A to finish before sending Request B.
- **Pros:** Safe; works with anything.
- **Cons:** Slow. If the network is laggy, the "Save" indicator may spin for a long time.
```ts
new AsyncAdapter({
concurrency: 'sequential',
write: async (config): Promise => {
// This will not run in parallel with another write
await fetch('/api/settings', {
/*...*/
});
},
});
```
⠀
## 3. Handling Backend Responses on save
Sometimes, the server modifies the data you sent, e. g. sanitizing it.
The return type of your `write` callback is `AdapterEnvelope | void`, where `AdapterEnvelope` is:
```ts
{
config: unknown;
metadata: ManagerMetadata;
}
```
Return `void`: The library keeps the "Optimistic Update" (the value the user set).
Return `AdapterEnvelope`: The library silently updates the store with the data returned from the server.
```ts
const apiAdapter = new AsyncAdapter({
write: async (config, _lastCommittedConfig, metadata, signal) => {
const res = await fetch('/api/settings', {
/*...*/
});
const json = await res.json();
// AdapterEnvelopeSchema is a Zod schema that parses the payload as `{config, metadata}`.
// Assuming server returns `{data: {config, metadata}}`
return AdapterEnvelopeSchema.parse(json?.data);
},
});
```
# Loading and Error States
WIP
# Loading and Error States
When using the `AsyncAdapter`, you want to handle loading and error states.
The library provides granular status flags to handle loading screens, error boundaries, and notifications.
⠀
## Loading state
### Using defaults while settings are loading
One of the core features of `@config-store` is strict Zod validation with default values.
When you initialize the `ConfigManager`, the store is **immediately** populated with the default values defined in your Zod schema. This happens _before_ `adapter.read()` returns data.
This means you often **do not need a loading state**. Your UI will render immediately with valid default settings, and then "hydrate" with user preferences once the adapter loads.
```tsx
// Even if load() is pending, this returns `true` (if that is the default in schema)
const isMenuExpanded = useConfig((c) => c.menuExpanded);
return ;
```
The downside of this approach is that the user **sees a flash of defualt settings** before user's preferences load.
⠀
### Showing loading state while settings are loading
If your application depends heavily on user settings to render the initial layout (e.g., to avoid layout shift), you can check the `hasBeenHydrated` or `isLoadPending` flags.
You can access these flags by passing a selector to `useConfig`:
```tsx
import {useConfig} from './settings/hooks';
export const App = () => {
// Select the entire state to access status flags
const isLoaded = useConfig((_c, state) => state.hasBeenHydrated);
// OR check pending specifically
const isLoading = useConfig((_c, state) => state.isLoadPending);
if (isLoading) {
return ;
}
return ;
};
```
⠀
## Showing error state when setting failed to load
If the adapter fails to read (e.g., network timeout), the manager enters an error state. You can detect this locally in a component or globally via callbacks.
⠀
### Local handling (Try-Catch)
The `manager.load()` method returns a `Promise`. If the adapter fails to read, the promise rejects (in addition to setting the internal error state).
You can wrap the call in a standard `try-catch` block to handle initialization errors imperatively. This is common in the application entry point (`main.tsx`) to prevent the app from mounting if critical configuration is missing.
```tsx
// src/main.tsx
async function init() {
let app: ReactNode = ;
try {
// Wait for settings to load
await configManager.load();
} catch (error) {
// If it fails, render a specific fatal error screen
// instead of the main application.
app = ;
}
// Render app only on success
ReactDOM.createRoot(document.getElementById('root')!).render(app);
}
init();
```
⠀
### React-specific handling (Route Loaders)
In modern React architectures (like **TanStack Router** or **React Router 6.4+**), the recommended way to handle async errors is via **Route Loaders** and **Error Boundaries**.
Instead of managing `try-catch` blocks or `useEffect` hooks, you simply return `configManager.load()` in your root route's loader. If the promise rejects, the router automatically catches it and renders the configured Error Component.
Note: If your settings require authentication, you should avoid calling `load()` for anonymous users. This prevents unnecessary network requests that would result in 401 errors. Since the `ConfigManager` is already initialized with default values, you can simply **skip** the loading process if the user is not logged in.
```tsx
// src/routes/__root.tsx
import {createRootRoute} from '@tanstack/react-router';
import {configManager} from '../settings/manager';
import {authStore} from '../auth/store';
export const Route = createRootRoute({
loader: async () => {
// 1. Check if user is logged in
const {isAuthenticated} = authStore.getState();
// 2. Only fetch settings if authenticated
if (isAuthenticated) {
await configManager.load();
}
// 3. Otherwise, do nothing. The app will proceed using
// the default config defined in your Zod schema.
},
component: RootLayout,
});
```
⠀
### Global handling
When creating the manager, you can provide an `onLoadError` callback. This is useful for logging to services like Sentry.
```ts
const manager = ConfigManager.create(
{
adapter,
onLoadError: (error) => {
console.error('Failed to load settings', error);
Sentry.captureException(error);
toast.error('Failed to load settings');
},
},
{
/* ... */
}
);
```
## Showing error state when setting failed to save
When you call `update()`, the library performs an **Optimistic Update**. The store updates immediately. If the adapter fails to write the change, the store sets `isSaveError` to true.
The `useUpdateConfig` hook returns the status of the _current_ update operation.
```tsx
export const SaveButton = () => {
const {update, isPending, isError, error} = useUpdateConfig();
return (
);
};
```
## Showing a toast when setting failed to save
For a better UX, you usually want to show a toast notification if a background save fails, rather than handling `isError` in every single component.
You can configure a global `onSaveError` handler when initializing the manager.
```ts
import {ConfigManager, LocalStorageAdapter} from '@config-store/core';
import {z} from 'zod';
import toast from 'react-hot-toast'; // or your preferred library
export const configManager = ConfigManager.create(
// Config manager options
{
adapter: new LocalStorageAdapter(),
// Global error handler
onSaveError: (error) => {
const message = error instanceof Error ? error.message : 'Unknown error';
toast.error(`Could not save settings: ${message}`);
},
// You can also handle migration errors here
onMigrationError: ({error}) => {
toast.error('Failed to migrate settings version');
console.error(error);
},
},
// Initial version
{
version: 1,
schema: z
.object({
/* ... */
})
.prefault({}),
}
);
```
# Frequently Asked Questions
### Should I use TanStack Query in the adapter?
**Probably not.**
TanStack Query (React Query) is designed for **Server State**. This library manages **Client State**. If you use TanStack Query inside the adapter, you are effectively caching the data twice.
If you know what you're doing, you _can_ bridge them using `queryClient.fetchQuery` inside `adapter.read()` and `queryClient.setQueryData` inside `adapter.write()`.
⠀
### Why does the library depend on Zustand?
The `@config-store/core` package uses `zustand/vanilla` internally as a micro-dependency (<1kb) for the underlying store. The `@config-store/react` package uses `zustand`.
Zustand provides a robust store implementation with selector support, e. g. `useConfig(s => s.theme)`. This prevents unnecessary re-renders that would occur with standard React Context. For example, if a component relies on property A to render, then changes to property B should not cause the component to rerender.
⠀
### What's the hassle with migrations?
Config schemas change over time as your project matures. For example, dark theme was managed via `darkTheme: boolean` setting, but now it's `theme: 'dark' | 'light' | 'system'`.
Without migrations, a user returning after 6 months will experience a crash because their localStorage data doesn't match your new code. To work around the crash, you'll have to reset their settings to defaults.
`@config-store` lets you define a migration, that will change the user's config to the new format without discarding their preferences.
Migrations are applied transparently, keeping your UI code clean and typed strictly to the _latest_ version.
⠀
### What happens if I omit a migration?
If a new config version does not define a migration, user settings will be used as-is for this version. This is fine in cases where your schema changes are minor and do not result in different types.
However, if `adapter.read()` returns data that does not match the current Zod schema, **Zod will throw a validation error**. The `ConfigManager` catches this error, logs it, and **falls back to default values** to prevent a White Screen of Death. With proper migrations set up, this should only happen when settings are edited in the database in violation of the frontend schema.
⠀
### How do I reset a setting to its default value?
Pass `undefined` to the update hook: `updateConfig({ theme: undefined })`. Zod will apply the `.default()` value defined in your schema.
# Manage frontend settings transparently
> A schema-first, strictly typed config manager with blackjack and migrations!
import {Card, CardGrid} from '@astrojs/starlight/components';
## Features
Store user settings feature flags or any persistent client-state in a centralized JSON-like
structure.
The config is defined as a [Zod](https://zod.dev) schema, providing strict TypeScript inference
across your codebase. Each setting can be anything from a `boolean` to a complex nested object.
The Zod schema also provides defaults for each value.
As your schema changes, define migration functions to automatically update a user's config to
conform to the new schema. This process is transparent to the consuming app.{' '}
Ships with a simple `LocalStorageAdapter` and a versatile `AsyncAdapter` (e. g. for REST APIs).
You can easily define custom adapters for other protocols (e.g., WebSocket, IndexedDB).
The `AsyncAdapter` provides three strategies for parallel writes:
**abort**: Cancels previous pending requests (default, relies on AbortController).
**optimistic concurrency control**: On top of the **abort** strategy, your backend can emit
`409 Conflict` on an attempt to overwrite an newer config version with a newer one.
**sequential**: Waits for each update to finish before processing the next one. Updates pile
up in a queue. Useful for legacy backends, at the cost of UX.
The core can be used with vanilla JS or in any framework.
The following framework integrations are available:
**React**: Provides hooks like `useConfig` and `useUpdateConfig`. Makes sure your components rerender only when the relevant individual settings change. Unrelated changes to the config will not cause rerenders.
Support for other frameworks is not planned, but contributions are very welcome.
# AdapterPayloadError
Defined in: [packages/core/src/errors.ts:84](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L84)
Error class to handle adapter payload parse errors. Expects to receive a ZodError.
## Extends
- [`BaseError`](/api/core/src/classes/baseerror/)
## Constructors
### Constructor
> **new AdapterPayloadError**(`error`): `AdapterPayloadError`
Defined in: [packages/core/src/errors.ts:85](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L85)
#### Parameters
##### error
`unknown`
#### Returns
`AdapterPayloadError`
#### Overrides
[`BaseError`](/api/core/src/classes/baseerror/).[`constructor`](/api/core/src/classes/baseerror/#constructor)
## Properties
### cause?
> `readonly` `optional` **cause**: `unknown`
Defined in: [packages/core/src/errors.ts:14](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L14)
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`cause`](/api/core/src/classes/baseerror/#cause)
***
### message
> **message**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1077
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`message`](/api/core/src/classes/baseerror/#message)
***
### name
> **name**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1076
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`name`](/api/core/src/classes/baseerror/#name)
***
### stack?
> `optional` **stack**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1078
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`stack`](/api/core/src/classes/baseerror/#stack)
# AsyncAdapter
Defined in: [packages/core/src/adapters/async.ts:55](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L55)
An adapter designed for asynchronous persistence, such as REST APIs.
Includes built-in support for concurrency control (AbortController or Sequential Queue)
and error handling.
It is not intended to be subclassed (though you can if you know what you're doing).
Instead, it's supposed to be instantiated with `new AsyncAdapter(options)`, passing
[AsyncAdapterOptions](/api/core/src/interfaces/asyncadapteroptions/) for customization.
See [documentation](https://config-store.lolma.us/guides/adapters/async/) for usage guide.
## Extends
- [`BaseAdapter`](/api/core/src/classes/baseadapter/)
## Constructors
### Constructor
> **new AsyncAdapter**(`options`): `AsyncAdapter`
Defined in: [packages/core/src/adapters/async.ts:65](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L65)
#### Parameters
##### options
[`AsyncAdapterOptions`](/api/core/src/interfaces/asyncadapteroptions/)
#### Returns
`AsyncAdapter`
#### Overrides
[`BaseAdapter`](/api/core/src/classes/baseadapter/).[`constructor`](/api/core/src/classes/baseadapter/#constructor)
## Methods
### read()
> **read**(): `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
Defined in: [packages/core/src/adapters/async.ts:70](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L70)
Retrieves the current settings and optional metadata from the storage medium.
#### Returns
`Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
An `AdapterEnvelope` containing config and metadata,
or `null`/`undefined`/`void` if empty, depending on adapter implementation.
#### Overrides
[`BaseAdapter`](/api/core/src/classes/baseadapter/).[`read`](/api/core/src/classes/baseadapter/#read)
***
### write()
> **write**(`nextConfig`, `metadata`): `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
Defined in: [packages/core/src/adapters/async.ts:79](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L79)
Persists changes to the storage medium.
#### Parameters
##### nextConfig
`unknown`
The full settings object to be saved.
##### metadata
[`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
The opaque metadata (e.g. dataVersion) from the Manager.
#### Returns
`Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
The saved envelope (if the backend modifies it), or void/null/undefined.
#### Overrides
[`BaseAdapter`](/api/core/src/classes/baseadapter/).[`write`](/api/core/src/classes/baseadapter/#write)
# BaseAdapter
Defined in: [packages/core/src/adapters/base.ts:8](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/base.ts#L8)
Abstract base class for all storage adapters.
Implementations must handle reading and writing the `AdapterEnvelope` to a persistence layer.
## Extended by
- [`AsyncAdapter`](/api/core/src/classes/asyncadapter/)
- [`LocalStorageAdapter`](/api/core/src/classes/localstorageadapter/)
## Constructors
### Constructor
> **new BaseAdapter**(): `BaseAdapter`
#### Returns
`BaseAdapter`
## Methods
### read()
> `abstract` **read**(): `void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\> \| `null` \| `undefined`
Defined in: [packages/core/src/adapters/base.ts:15](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/base.ts#L15)
Retrieves the current settings and optional metadata from the storage medium.
#### Returns
`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\> \| `null` \| `undefined`
An `AdapterEnvelope` containing config and metadata,
or `null`/`undefined`/`void` if empty, depending on adapter implementation.
***
### write()
> `abstract` **write**(`nextConfig`, `metadata`): `void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\> \| `null` \| `undefined`
Defined in: [packages/core/src/adapters/base.ts:29](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/base.ts#L29)
Persists changes to the storage medium.
#### Parameters
##### nextConfig
`unknown`
The full settings object to be saved.
##### metadata
[`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
The opaque metadata (e.g. dataVersion) from the Manager.
#### Returns
`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\> \| `null` \| `undefined`
The saved envelope (if the backend modifies it), or void/null/undefined.
# BaseError
Defined in: [packages/core/src/errors.ts:12](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L12)
Abstract Base Error to centralize stack trace and prototype logic.
## Extends
- `Error`
## Extended by
- [`ConfigConflictError`](/api/core/src/classes/configconflicterror/)
- [`ConfigSchemaOutdatedError`](/api/core/src/classes/configschemaoutdatederror/)
- [`AdapterPayloadError`](/api/core/src/classes/adapterpayloaderror/)
## Constructors
### Constructor
> **new BaseError**(`message`, `options`): `BaseError`
Defined in: [packages/core/src/errors.ts:16](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L16)
#### Parameters
##### message
`string`
##### options
###### cause?
`unknown`
#### Returns
`BaseError`
#### Overrides
`Error.constructor`
## Properties
### cause?
> `readonly` `optional` **cause**: `unknown`
Defined in: [packages/core/src/errors.ts:14](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L14)
#### Overrides
`Error.cause`
***
### message
> **message**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1077
#### Inherited from
`Error.message`
***
### name
> **name**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1076
#### Inherited from
`Error.name`
***
### stack?
> `optional` **stack**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1078
#### Inherited from
`Error.stack`
# ConfigConflictError
Defined in: [packages/core/src/errors.ts:38](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L38)
Error class to handle confilcts
## Extends
- [`BaseError`](/api/core/src/classes/baseerror/)
## Constructors
### Constructor
> **new ConfigConflictError**(`serverEnvelope`): `ConfigConflictError`
Defined in: [packages/core/src/errors.ts:41](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L41)
#### Parameters
##### serverEnvelope
[`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)
#### Returns
`ConfigConflictError`
#### Overrides
[`BaseError`](/api/core/src/classes/baseerror/).[`constructor`](/api/core/src/classes/baseerror/#constructor)
## Properties
### cause?
> `readonly` `optional` **cause**: `unknown`
Defined in: [packages/core/src/errors.ts:14](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L14)
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`cause`](/api/core/src/classes/baseerror/#cause)
***
### message
> **message**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1077
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`message`](/api/core/src/classes/baseerror/#message)
***
### name
> **name**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1076
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`name`](/api/core/src/classes/baseerror/#name)
***
### serverEnvelope
> `readonly` **serverEnvelope**: [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)
Defined in: [packages/core/src/errors.ts:39](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L39)
***
### stack?
> `optional` **stack**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1078
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`stack`](/api/core/src/classes/baseerror/#stack)
# ConfigManager
Defined in: [packages/core/src/manager.ts:20](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L20)
The main class managing configuration state, persistence, validation, and version migration.
It uses a Zustand store internally to maintain reactivity.
## Type Parameters
### TCurrent
`TCurrent` = `undefined`
The type of the current configuration schema.
## Properties
### store
> **store**: `StoreApi`\<[`ManagerState`](/api/core/src/interfaces/managerstate/)\<`TCurrent`\>\>
Defined in: [packages/core/src/manager.ts:33](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L33)
The underlying Zustand store instance.
Can be used to subscribe to state changes directly.
## Accessors
### config
#### Get Signature
> **get** **config**(): `TCurrent`
Defined in: [packages/core/src/manager.ts:108](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L108)
The current stored config.
##### Returns
`TCurrent`
***
### dataVersion
#### Get Signature
> **get** **dataVersion**(): `number`
Defined in: [packages/core/src/manager.ts:118](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L118)
The current data version number.
##### Returns
`number`
***
### hasBeenHydrated
#### Get Signature
> **get** **hasBeenHydrated**(): `boolean`
Defined in: [packages/core/src/manager.ts:128](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L128)
True if the store has successfully loaded or saved data at least once.
##### Returns
`boolean`
***
### isLoadError
#### Get Signature
> **get** **isLoadError**(): `boolean`
Defined in: [packages/core/src/manager.ts:158](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L158)
True if load status is 'error'.
##### Returns
`boolean`
***
### isLoadInitial
#### Get Signature
> **get** **isLoadInitial**(): `boolean`
Defined in: [packages/core/src/manager.ts:143](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L143)
True if load status is 'initial'.
##### Returns
`boolean`
***
### isLoadPending
#### Get Signature
> **get** **isLoadPending**(): `boolean`
Defined in: [packages/core/src/manager.ts:148](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L148)
True if load status is 'pending'.
##### Returns
`boolean`
***
### isLoadSuccess
#### Get Signature
> **get** **isLoadSuccess**(): `boolean`
Defined in: [packages/core/src/manager.ts:153](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L153)
True if load status is 'success'.
##### Returns
`boolean`
***
### loadError
#### Get Signature
> **get** **loadError**(): `unknown`
Defined in: [packages/core/src/manager.ts:138](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L138)
The error from the last load operation, if any.
##### Returns
`unknown`
***
### loadStatus
#### Get Signature
> **get** **loadStatus**(): [`ManagerStatus`](/api/core/src/type-aliases/managerstatus/)
Defined in: [packages/core/src/manager.ts:133](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L133)
The status of the load operation.
##### Returns
[`ManagerStatus`](/api/core/src/type-aliases/managerstatus/)
***
### metadata
#### Get Signature
> **get** **metadata**(): [`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
Defined in: [packages/core/src/manager.ts:113](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L113)
The metadata (data version and schema version).
##### Returns
[`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
***
### schemaVersion
#### Get Signature
> **get** **schemaVersion**(): `number`
Defined in: [packages/core/src/manager.ts:123](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L123)
The current schema version number.
##### Returns
`number`
***
### state
#### Get Signature
> **get** **state**(): [`ManagerState`](/api/core/src/interfaces/managerstate/)\<`TCurrent`\>
Defined in: [packages/core/src/manager.ts:103](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L103)
The entire state snapshot of the manager, including config, metadata and load/save state.
##### Returns
[`ManagerState`](/api/core/src/interfaces/managerstate/)\<`TCurrent`\>
## Methods
### addVersion()
> **addVersion**\<`TNext`\>(`versionDef`): `ConfigManager`\<`TNext`\>
Defined in: [packages/core/src/manager.ts:174](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L174)
Defines the next version of the configuration schema.
This method uses an immutable builder pattern and returns a *new* ConfigManager instance
typed with the new schema.
#### Type Parameters
##### TNext
`TNext`
#### Parameters
##### versionDef
[`VersionDef`](/api/core/src/interfaces/versiondef/)\<`TCurrent`, `TNext`\>
The definition of the new version, including schema and migration function.
#### Returns
`ConfigManager`\<`TNext`\>
A new ConfigManager instance.
***
### load()
> **load**(): `Promise`\<`void`\>
Defined in: [packages/core/src/manager.ts:197](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L197)
Loads the configuration from the adapter.
Handles deserialization, validation, and migration of data.
Updates the store with the result.
#### Returns
`Promise`\<`void`\>
***
### save()
> **save**(`config`): `Promise`\<`TCurrent`\>
Defined in: [packages/core/src/manager.ts:226](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L226)
Saves the configuration to the adapter.
Performs an optimistic update on the store immediately.
Handles race conditions and version conflicts.
#### Parameters
##### config
`TCurrent`
The new configuration to save.
#### Returns
`Promise`\<`TCurrent`\>
The resolved configuration (may differ from input if server modified it or if race condition occurred).
***
### create()
> `static` **create**\<`TConfig`\>(`options`, `initialVersion`): `ConfigManager`\<`TConfig`\>
Defined in: [packages/core/src/manager.ts:91](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/manager.ts#L91)
Creates a new ConfigManager instance.
#### Type Parameters
##### TConfig
`TConfig`
#### Parameters
##### options
[`ConfigManagerOptions`](/api/core/src/interfaces/configmanageroptions/)
##### initialVersion
[`VersionDef`](/api/core/src/interfaces/versiondef/)\<`void`, `TConfig`\>
The definition of the initial schema version (Version 1).
#### Returns
`ConfigManager`\<`TConfig`\>
A ConfigManager instance typed with the initial schema.
# ConfigSchemaOutdatedError
Defined in: [packages/core/src/errors.ts:50](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L50)
Error class to saved schemaVersion being higher than current latest schema
## Extends
- [`BaseError`](/api/core/src/classes/baseerror/)
## Constructors
### Constructor
> **new ConfigSchemaOutdatedError**(`incomingVersion`, `currentVersion`): `ConfigSchemaOutdatedError`
Defined in: [packages/core/src/errors.ts:54](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L54)
#### Parameters
##### incomingVersion
`number`
##### currentVersion
`number`
#### Returns
`ConfigSchemaOutdatedError`
#### Overrides
[`BaseError`](/api/core/src/classes/baseerror/).[`constructor`](/api/core/src/classes/baseerror/#constructor)
## Properties
### cause?
> `readonly` `optional` **cause**: `unknown`
Defined in: [packages/core/src/errors.ts:14](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L14)
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`cause`](/api/core/src/classes/baseerror/#cause)
***
### currentVersion
> `readonly` **currentVersion**: `number`
Defined in: [packages/core/src/errors.ts:52](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L52)
***
### incomingVersion
> `readonly` **incomingVersion**: `number`
Defined in: [packages/core/src/errors.ts:51](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/errors.ts#L51)
***
### message
> **message**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1077
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`message`](/api/core/src/classes/baseerror/#message)
***
### name
> **name**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1076
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`name`](/api/core/src/classes/baseerror/#name)
***
### stack?
> `optional` **stack**: `string`
Defined in: node\_modules/.pnpm/typescript@5.9.2/node\_modules/typescript/lib/lib.es5.d.ts:1078
#### Inherited from
[`BaseError`](/api/core/src/classes/baseerror/).[`stack`](/api/core/src/classes/baseerror/#stack)
# LocalStorageAdapter
Defined in: [packages/core/src/adapters/local-storage.ts:21](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L21)
A synchronous adapter for persistence to the browser's LocalStorage.
It wraps the data in an envelope `{ config: ..., metadata: ... }`
to support versioning and other metadata.
## Extends
- [`BaseAdapter`](/api/core/src/classes/baseadapter/)
## Constructors
### Constructor
> **new LocalStorageAdapter**(`options?`): `LocalStorageAdapter`
Defined in: [packages/core/src/adapters/local-storage.ts:24](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L24)
#### Parameters
##### options?
[`LocalStorageAdapterOptions`](/api/core/src/interfaces/localstorageadapteroptions/)
#### Returns
`LocalStorageAdapter`
#### Overrides
[`BaseAdapter`](/api/core/src/classes/baseadapter/).[`constructor`](/api/core/src/classes/baseadapter/#constructor)
## Properties
### key
> **key**: `string` = `'@lolmaus/config-store'`
Defined in: [packages/core/src/adapters/local-storage.ts:22](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L22)
## Methods
### read()
> **read**(): `void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\>
Defined in: [packages/core/src/adapters/local-storage.ts:30](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L30)
Retrieves the current settings and optional metadata from the storage medium.
#### Returns
`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\>
An `AdapterEnvelope` containing config and metadata,
or `null`/`undefined`/`void` if empty, depending on adapter implementation.
#### Overrides
[`BaseAdapter`](/api/core/src/classes/baseadapter/).[`read`](/api/core/src/classes/baseadapter/#read)
***
### write()
> **write**(`nextConfig`, `metadata`): `void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\>
Defined in: [packages/core/src/adapters/local-storage.ts:48](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L48)
Persists changes to the storage medium.
#### Parameters
##### nextConfig
`unknown`
The full settings object to be saved.
##### metadata
[`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
The opaque metadata (e.g. dataVersion) from the Manager.
#### Returns
`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\>
The saved envelope (if the backend modifies it), or void/null/undefined.
#### Overrides
[`BaseAdapter`](/api/core/src/classes/baseadapter/).[`write`](/api/core/src/classes/baseadapter/#write)
# AdapterEnvelope
Defined in: [packages/core/src/types.ts:79](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L79)
The data structure exchanged between the Manager and the Adapter.
Wraps the actual config with metadata to ensure data integrity and versioning.
## Type Parameters
### TCurrent
`TCurrent` = `unknown`
The type of the configuration.
## Properties
### config
> **config**: `TCurrent`
Defined in: [packages/core/src/types.ts:80](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L80)
***
### metadata
> **metadata**: [`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
Defined in: [packages/core/src/types.ts:81](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L81)
# AsyncAdapterOptions
Defined in: [packages/core/src/adapters/async.ts:14](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L14)
Configuration options for the `AsyncAdapter`.
## Properties
### concurrency?
> `optional` **concurrency**: [`ConcurrencyStrategy`](/api/core/src/type-aliases/concurrencystrategy/)
Defined in: [packages/core/src/adapters/async.ts:41](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L41)
The concurrency strategy to use. Defaults to `'abort'`.
***
### read()
> **read**: () => `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
Defined in: [packages/core/src/adapters/async.ts:21](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L21)
Function to retrieve data from the remote source.
#### Returns
`Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
Should return [AdapterEnvelope](/api/core/src/interfaces/adapterenvelope/) if the backend responds with data.
When the backend has no config stored for the user, return `null` or `undefined`.
***
### write()
> **write**: (`nextConfig`, `lastCommittedConfig`, `metadata`, `signal?`) => `Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
Defined in: [packages/core/src/adapters/async.ts:33](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L33)
Function to persist data to the remote source.
#### Parameters
##### nextConfig
`unknown`
The new configuration object.
##### lastCommittedConfig
`unknown`
The last known confirmed configuration from the server (useful for PATCH/Diffing).
##### metadata
[`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
The versioning metadata.
##### signal?
`AbortSignal`
An AbortSignal (if concurrency is set to 'abort').
#### Returns
`Promise`\<`void` \| [`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)\<`unknown`\> \| `null` \| `undefined`\>
Should return [AdapterEnvelope](/api/core/src/interfaces/adapterenvelope/) if the backend responds with updated data.
Otherwise, may return `null` or `undefined`.
# ConfigManagerOptions
Defined in: [packages/core/src/types.ts:136](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L136)
Options for configuring the behavior of the ConfigManager.
## Properties
### adapter
> **adapter**: [`BaseAdapter`](/api/core/src/classes/baseadapter/)
Defined in: [packages/core/src/types.ts:138](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L138)
The adapter instance to use for persistence.
***
### onLoadError?
> `optional` **onLoadError**: [`OnLoadError`](/api/core/src/type-aliases/onloaderror/)
Defined in: [packages/core/src/types.ts:140](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L140)
***
### onMigrationError?
> `optional` **onMigrationError**: [`OnMigrationError`](/api/core/src/type-aliases/onmigrationerror/)
Defined in: [packages/core/src/types.ts:142](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L142)
***
### onSaveError?
> `optional` **onSaveError**: [`OnSaveError`](/api/core/src/type-aliases/onsaveerror/)
Defined in: [packages/core/src/types.ts:141](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L141)
# LocalStorageAdapterOptions
Defined in: [packages/core/src/adapters/local-storage.ts:8](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L8)
Options for the LocalStorageAdapter.
## Properties
### key?
> `optional` **key**: `string`
Defined in: [packages/core/src/adapters/local-storage.ts:13](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/local-storage.ts#L13)
The key under which the settings will be stored in localStorage.
Defaults to `'@lolmaus/config-store'`.
# ManagerMetadata
Defined in: [packages/core/src/types.ts:60](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L60)
Metadata used for Optimistic Concurrency Control and schema validation.
## Properties
### dataVersion
> **dataVersion**: `number`
Defined in: [packages/core/src/types.ts:65](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L65)
Monotonically increasing number representing the version of the data.
Used to detect write conflicts in async adapters.
***
### schemaVersion
> **schemaVersion**: `number`
Defined in: [packages/core/src/types.ts:70](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L70)
The version of the schema that the data adheres to.
Used to trigger migrations.
# ManagerState
Defined in: [packages/core/src/types.ts:20](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L20)
The internal state of the ConfigManager, exposed via a Zustand store.
This interface contains the stored config, metadata, and granular loading/saving status flags.
## Type Parameters
### TConfig
`TConfig`
The shape of the configuration object.
## Properties
### config
> `readonly` **config**: `TConfig`
Defined in: [packages/core/src/types.ts:22](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L22)
The current configuration object.
***
### hasBeenHydrated
> `readonly` **hasBeenHydrated**: `boolean`
Defined in: [packages/core/src/types.ts:26](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L26)
Indicates if the store has been populated with data from the adapter at least once.
***
### isLoadError
> `readonly` **isLoadError**: `boolean`
Defined in: [packages/core/src/types.ts:40](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L40)
True if load status is 'error'.
***
### isLoadInitial
> `readonly` **isLoadInitial**: `boolean`
Defined in: [packages/core/src/types.ts:34](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L34)
True if load status is 'initial'.
***
### isLoadPending
> `readonly` **isLoadPending**: `boolean`
Defined in: [packages/core/src/types.ts:36](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L36)
True if load status is 'pending'.
***
### isLoadSuccess
> `readonly` **isLoadSuccess**: `boolean`
Defined in: [packages/core/src/types.ts:38](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L38)
True if load status is 'success'.
***
### isSaveError
> `readonly` **isSaveError**: `boolean`
Defined in: [packages/core/src/types.ts:54](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L54)
True if save status is 'error'.
***
### isSaveInitial
> `readonly` **isSaveInitial**: `boolean`
Defined in: [packages/core/src/types.ts:48](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L48)
True if save status is 'initial'.
***
### isSavePending
> `readonly` **isSavePending**: `boolean`
Defined in: [packages/core/src/types.ts:50](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L50)
True if save status is 'pending'.
***
### isSaveSuccess
> `readonly` **isSaveSuccess**: `boolean`
Defined in: [packages/core/src/types.ts:52](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L52)
True if save status is 'success'.
***
### loadError
> `readonly` **loadError**: `unknown`
Defined in: [packages/core/src/types.ts:32](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L32)
The error object if the load operation failed. `null` if successful, idle or pending.
***
### loadStatus
> `readonly` **loadStatus**: [`ManagerStatus`](/api/core/src/type-aliases/managerstatus/)
Defined in: [packages/core/src/types.ts:30](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L30)
The specific status of the load operation.
***
### metadata
> `readonly` **metadata**: [`ManagerMetadata`](/api/core/src/interfaces/managermetadata/)
Defined in: [packages/core/src/types.ts:24](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L24)
Metadata regarding data versions and schema versions.
***
### saveError
> `readonly` **saveError**: `unknown`
Defined in: [packages/core/src/types.ts:46](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L46)
The error object if the save operation failed. `null` if successful, idle or pending.
***
### saveStatus
> `readonly` **saveStatus**: [`ManagerStatus`](/api/core/src/type-aliases/managerstatus/)
Defined in: [packages/core/src/types.ts:44](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L44)
The specific status of the save operation.
# VersionDef
Defined in: [packages/core/src/types.ts:90](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L90)
Defines a specific version of the configuration schema and how to migrate to it.
## Type Parameters
### TPrev
`TPrev`
The type of the configuration in the previous version.
### TNext
`TNext`
The type of the configuration in this version.
## Properties
### migration()?
> `optional` **migration**: (`prev`) => `TNext`
Defined in: [packages/core/src/types.ts:99](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L99)
A function that transforms the configuration from the previous version (`TPrev`)
to this version (`TNext`).
#### Parameters
##### prev
`TPrev`
#### Returns
`TNext`
***
### schema
> **schema**: `ZodType`\<`TNext`\>
Defined in: [packages/core/src/types.ts:94](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L94)
The Zod schema defining the shape and defaults of this version.
***
### version
> **version**: `number`
Defined in: [packages/core/src/types.ts:92](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L92)
The schema version number (must be incremental).
# ConcurrencyStrategy
> **ConcurrencyStrategy** = `"abort"` \| `"sequential"`
Defined in: [packages/core/src/adapters/async.ts:9](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/adapters/async.ts#L9)
Strategy for handling multiple concurrent write requests.
- `'abort'`: Cancels the previous pending request using AbortController (Best for modern APIs).
- `'sequential'`: Queues requests to ensure they run one after another (Best for legacy backends).
# InferConfig
> **InferConfig**\<`T`\> = `T` *extends* [`ConfigManager`](/api/core/src/classes/configmanager/)\ ? `C` : `never`
Defined in: [packages/core/src/types.ts:107](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L107)
Utility type to infer the configuration shape from a `ConfigManager` instance.
## Type Parameters
### T
`T`
The ConfigManager instance type.
# ManagerStatus
> **ManagerStatus** = `"initial"` \| `"pending"` \| `"success"` \| `"error"`
Defined in: [packages/core/src/types.ts:12](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L12)
Represents the current status of an asynchronous operation within the Manager.
- `initial`: No operation has been attempted yet.
- `pending`: An operation is currently in progress.
- `success`: The last operation completed successfully.
- `error`: The last operation failed.
# OnLoadError
> **OnLoadError** = (`error`) => `void`
Defined in: [packages/core/src/types.ts:125](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L125)
## Parameters
### error
`unknown`
## Returns
`void`
# OnMigrationError
> **OnMigrationError** = (`arg`) => `void`
Defined in: [packages/core/src/types.ts:127](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L127)
## Parameters
### arg
#### currentEnvelope
[`AdapterEnvelope`](/api/core/src/interfaces/adapterenvelope/)
#### error
`unknown`
#### versionDef
[`VersionDef`](/api/core/src/interfaces/versiondef/)\<`unknown`, `unknown`\>
## Returns
`void`
# OnSaveError
> **OnSaveError** = (`error`) => `void`
Defined in: [packages/core/src/types.ts:126](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L126)
## Parameters
### error
`unknown`
## Returns
`void`
# AdapterEnvelopeSchema
> `const` **AdapterEnvelopeSchema**: `ZodObject`\<\{ `config`: `ZodUnknown`; `metadata`: `ZodObject`\<\{ `dataVersion`: `ZodNumber`; `schemaVersion`: `ZodNumber`; \}, `$strip`\>; \}, `$strip`\>
Defined in: [packages/core/src/types.ts:120](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L120)
Runtime Zod schema for validating `AdapterEnvelope`.
# MetadataSchema
> `const` **MetadataSchema**: `ZodObject`\<\{ `dataVersion`: `ZodNumber`; `schemaVersion`: `ZodNumber`; \}, `$strip`\>
Defined in: [packages/core/src/types.ts:112](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/core/src/types.ts#L112)
Runtime Zod schema for validating `ManagerMetadata`.
# ConfigProvider
> **ConfigProvider**\<`T`\>(`__namedParameters`): `Element`
Defined in: [packages/react/src/provider.tsx:16](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/provider.tsx#L16)
Provides the ConfigManager to the application tree via React Context.
Required for `useConfig`, `useUpdateConfig` and `useUpdateConfigReducer` hooks to work.
## Type Parameters
### T
`T`
## Parameters
### \_\_namedParameters
[`ConfigProviderProps`](/api/react/src/interfaces/configproviderprops/)\<`T`\>
## Returns
`Element`
# createHooks
> **createHooks**\<`TConfig`\>(): `object`
Defined in: [packages/react/src/hooks.ts:188](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/hooks.ts#L188)
Creates a set of typed hooks bound to your specific Config type.
Use this to avoid passing the generic type `` to every hook usage.
## Type Parameters
### TConfig
`TConfig`
The type of the configuration.
## Returns
`object`
### useConfig()
> **useConfig**: \<`TSelected`\>(`selector?`) => `TSelected`
#### Type Parameters
##### TSelected
`TSelected` = `TConfig`
#### Parameters
##### selector?
(`config`, `state`) => `TSelected`
#### Returns
`TSelected`
### useUpdateConfig()
> **useUpdateConfig**: () => [`UseUpdateConfigResult`](/api/react/src/interfaces/useupdateconfigresult/)\<`TConfig`\>
#### Returns
[`UseUpdateConfigResult`](/api/react/src/interfaces/useupdateconfigresult/)\<`TConfig`\>
### useUpdateConfigReducer()
> **useUpdateConfigReducer**: \<`TPayload`\>(`reducer`) => [`UseUpdateConfigReducerResult`](/api/react/src/interfaces/useupdateconfigreducerresult/)\<`TConfig`, `TPayload`\>
#### Type Parameters
##### TPayload
`TPayload`
#### Parameters
##### reducer
[`ConfigReducer`](/api/react/src/type-aliases/configreducer/)\<`TConfig`, `TPayload`\>
#### Returns
[`UseUpdateConfigReducerResult`](/api/react/src/interfaces/useupdateconfigreducerresult/)\<`TConfig`, `TPayload`\>
# useConfig
Hook to read the config.
- If no selector is passed, it returns the entire config object.
- If a selector is passed, it returns a given property and prevents unnecessary rerenders.
## Call Signature
> **useConfig**\<`TConfig`\>(): `TConfig`
Defined in: [packages/react/src/hooks.ts:34](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/hooks.ts#L34)
Example:
```ts *
const mySettings: MySettings = useConfig();
```
⭐ Use with `createHooks` to avoid passing the `TConfig` generic explicitly:
```ts
export const {useConfig} = createHooks();
const mySettings: MySettings = useConfig();
```
### Type Parameters
#### TConfig
`TConfig`
The type of the configuration.
### Returns
`TConfig`
The entire configuration object.
## Call Signature
> **useConfig**\<`TConfig`, `TSelected`\>(`selector`): `TSelected`
Defined in: [packages/react/src/hooks.ts:56](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/hooks.ts#L56)
Pass a [ConfigSelector](/api/react/src/type-aliases/configselector/) function to access a specific property:
```ts
const theme: string = useConfig((c) => c.theme);
```
⭐ Use with `createHooks` to avoid passing the `TConfig` generic explicitly:
```ts
export const {useConfig} = createHooks();
const theme: string = useConfig((c) => c.theme);
```
### Type Parameters
#### TConfig
`TConfig`
The type of the configuration.
#### TSelected
`TSelected`
The selected value.
### Parameters
#### selector
[`ConfigSelector`](/api/react/src/type-aliases/configselector/)\<`TConfig`, `TSelected`\>
A function that selects a value from the config.
### Returns
`TSelected`
The selected value.
# useUpdateConfig
> **useUpdateConfig**\<`TConfig`\>(): [`UseUpdateConfigResult`](/api/react/src/interfaces/useupdateconfigresult/)\<`TConfig`\>
Defined in: [packages/react/src/hooks.ts:98](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/hooks.ts#L98)
Hook to update the configuration.
Supports direct replacement or inline mutation function.
## Type Parameters
### TConfig
`TConfig`
The type of the configuration.
## Returns
[`UseUpdateConfigResult`](/api/react/src/interfaces/useupdateconfigresult/)\<`TConfig`\>
An object containing the `update` function and status flags.
# useUpdateConfigReducer
> **useUpdateConfigReducer**\<`TConfig`, `TPayload`\>(`reducer`): [`UseUpdateConfigReducerResult`](/api/react/src/interfaces/useupdateconfigreducerresult/)\<`TConfig`, `TPayload`\>
Defined in: [packages/react/src/hooks.ts:147](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/hooks.ts#L147)
Hook to update the configuration using a Reducer pattern.
Best for complex logic or reusable actions.
## Type Parameters
### TConfig
`TConfig`
The type of the configuration.
### TPayload
`TPayload`
The type of the action payload accepted by the reducer.
## Parameters
### reducer
[`ConfigReducer`](/api/react/src/type-aliases/configreducer/)\<`TConfig`, `TPayload`\>
A function that takes current config and a payload, returning the new config.
## Returns
[`UseUpdateConfigReducerResult`](/api/react/src/interfaces/useupdateconfigreducerresult/)\<`TConfig`, `TPayload`\>
An object containing the `update(payload)` function and status flags.
# ConfigProviderProps
Defined in: [packages/react/src/provider.tsx:5](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/provider.tsx#L5)
## Type Parameters
### T
`T`
## Properties
### children
> **children**: `ReactNode`
Defined in: [packages/react/src/provider.tsx:9](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/provider.tsx#L9)
The React application or component tree to wrap.
***
### value
> **value**: [`ConfigManager`](/api/core/src/classes/configmanager/)\<`T`\>
Defined in: [packages/react/src/provider.tsx:7](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/provider.tsx#L7)
The initialized ConfigManager instance.
# UseUpdateConfigReducerResult
Defined in: [packages/react/src/types.ts:116](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L116)
Return value of the `useUpdateConfigReducer` hook.
Contains the dispatched update function and the current status of the save operation.
## Type Parameters
### TConfig
`TConfig`
### TPayload
`TPayload`
## Properties
### error
> **error**: `unknown`
Defined in: [packages/react/src/types.ts:136](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L136)
The error object if the save operation failed.
***
### isError
> **isError**: `boolean`
Defined in: [packages/react/src/types.ts:132](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L132)
True if save status is 'error'.
***
### isInitial
> **isInitial**: `boolean`
Defined in: [packages/react/src/types.ts:126](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L126)
True if save status is 'initial'.
***
### isPending
> **isPending**: `boolean`
Defined in: [packages/react/src/types.ts:128](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L128)
True if save status is 'pending'.
***
### isSuccess
> **isSuccess**: `boolean`
Defined in: [packages/react/src/types.ts:130](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L130)
True if save status is 'success'.
***
### status
> **status**: [`ManagerStatus`](/api/core/src/type-aliases/managerstatus/)
Defined in: [packages/react/src/types.ts:134](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L134)
The specific status of the save operation.
## Methods
### update()
> **update**(`payload`): `Promise`\<`TConfig`\>
Defined in: [packages/react/src/types.ts:123](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L123)
Updates the config by dispatching a payload to the defined reducer.
#### Parameters
##### payload
`TPayload`
The value passed into the update function that the reducer must apply to the config
#### Returns
`Promise`\<`TConfig`\>
The entire modified config
# UseUpdateConfigResult
Defined in: [packages/react/src/types.ts:82](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L82)
Return value of the `useUpdateConfig` hook.
Contains the update function and the current status of the save operation.
## Type Parameters
### TConfig
`TConfig`
The type of the config
## Properties
### error
> **error**: `unknown`
Defined in: [packages/react/src/types.ts:109](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L109)
The error object if the save operation failed, null if no error.
***
### isError
> **isError**: `boolean`
Defined in: [packages/react/src/types.ts:105](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L105)
True if save status is 'error'.
***
### isInitial
> **isInitial**: `boolean`
Defined in: [packages/react/src/types.ts:99](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L99)
True if save status is 'initial'.
***
### isPending
> **isPending**: `boolean`
Defined in: [packages/react/src/types.ts:101](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L101)
True if save status is 'pending'.
***
### isSuccess
> **isSuccess**: `boolean`
Defined in: [packages/react/src/types.ts:103](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L103)
True if save status is 'success'.
***
### status
> **status**: [`ManagerStatus`](/api/core/src/type-aliases/managerstatus/)
Defined in: [packages/react/src/types.ts:107](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L107)
The specific status of the save operation.
## Methods
### update()
#### Call Signature
> **update**(`config`): `Promise`\<`TConfig`\>
Defined in: [packages/react/src/types.ts:89](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L89)
Replaces the entire config with the provided value.
##### Parameters
###### config
`TConfig`
The entire config
##### Returns
`Promise`\<`TConfig`\>
The entire modified config
#### Call Signature
> **update**(`mutator`): `Promise`\<`TConfig`\>
Defined in: [packages/react/src/types.ts:96](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L96)
Updates the config using a mutator function.
##### Parameters
###### mutator
[`ConfigMutator`](/api/react/src/type-aliases/configmutator/)\<`TConfig`\>
The function that updates the config
##### Returns
`Promise`\<`TConfig`\>
The entire modified config
# ConfigMutator
> **ConfigMutator**\<`TConfig`\> = (`config`, `state`) => `TConfig`
Defined in: [packages/react/src/types.ts:53](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L53)
A pure function that transforms the current config.
⚠️ Despite, the name, you should not actually mutate the config. Instead, return a new config instance.
Optionally used in the `update` function returned by `useUpdateConfig()`.
Allows deriving the new state from the previous state.
Example:
```ts {4-7}
const {update} = useUpdateConfig();
update(
(config) => ({
...config,
theme: userInput,
})
);
```
## Type Parameters
### TConfig
`TConfig`
The type of the config
## Parameters
### config
`TConfig`
The entire config
### state
[`ManagerState`](/api/core/src/interfaces/managerstate/)\<`TConfig`\>
The state of ConfigManager, typically not needed
## Returns
`TConfig`
The entire modified config
# ConfigReducer
> **ConfigReducer**\<`TConfig`, `TPayload`\> = (`config`, `payload`, `state`) => `TConfig`
Defined in: [packages/react/src/types.ts:70](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L70)
A reducer that applies a given payload to the current config.
Passed into `useUpdateConfigReducer()` to produce a simplified `update` function
that only requires the payload.
Example:
## Type Parameters
### TConfig
`TConfig`
The type of the config
### TPayload
`TPayload`
The type of the value passed into the update function that the reducer must apply to the config
## Parameters
### config
`TConfig`
The entire config
### payload
`TPayload`
The value passed into the update function that the reducer must apply to the config
### state
[`ManagerState`](/api/core/src/interfaces/managerstate/)\<`TConfig`\>
The state of ConfigManager, typically not needed
## Returns
`TConfig`
The entire modified config
# ConfigSelector
> **ConfigSelector**\<`TConfig`, `TSelected`\> = (`config`, `state`) => `TSelected`
Defined in: [packages/react/src/types.ts:22](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/types.ts#L22)
A pure function that selects a value from the current config.
Used to optimize re-renders by only triggering updates when the selected value changes.
Example:
```ts "(config) => config.theme"
useConfig((config) => config.theme);
```
## Type Parameters
### TConfig
`TConfig`
The type of the configuration
### TSelected
`TSelected`
The selected value
## Parameters
### config
`TConfig`
The entire config
### state
[`ManagerState`](/api/core/src/interfaces/managerstate/)\<`TConfig`\>
The state of ConfigManager, typically not needed
## Returns
`TSelected`
The selected value
# ConfigContext
> `const` **ConfigContext**: `Context`\<[`ConfigManager`](/api/core/src/classes/configmanager/)\<`unknown`\> \| `null`\>
Defined in: [packages/react/src/context.ts:11](https://github.com/lolmaus/config-store/blob/d99d8f5738af2b61f98b0484dc210031233a295d/packages/react/src/context.ts#L11)
The Context holds the Manager instance.
We must use `unknown` here because React Context cannot preserve
the Generic type of the Manager created by the user.
The `useConfig` hook will cast this back to the user's specific Generic type.
# config-store
## Modules
- [core/src](/api/core/src/readme/)
- [react/src](/api/react/src/readme/)