@wrnexus/store
Application state stores shared across server and browser runtimes.
Install the package
After WorkRoot approves private registry access, install the release-aligned package:
bun add @wrnexus/store@0.8.7Request preview access. Never put registry tokens in source control.
Typed global and page-scoped WRNexusJS stores with runtime-specific state, computed values, actions, lifecycle hooks, persistence, SSR isolation, and HMR support.
Use defineStore() to declare a store and createStoreContainer() to create an isolated request or browser container. Store definitions are framework helpers and do not require UI components.
Complete TypeScript API
Generated from the exact installed package declarations.
import { StoreMutation, StoreFunction, StoreDefinition, StoreInstance, StoreCombinedState } from './types.js';
export { PersistenceStorage, StoreActionContext, StoreActionDefinition, StoreInstanceCore, StoreKind, StoreLifecycleContext, StorePersistenceConfig, StoreRuntime } from './types.js';
declare function defineStore<S extends object, C extends object = Record<string, never>, A extends Record<string, StoreFunction> = Record<string, StoreFunction>, CS extends object = Record<string, never>, SS extends object = Record<string, never>>(definition: StoreDefinition<S, C, A, CS, SS>): StoreDefinition<S, C, A, CS, SS>;
interface StoreContainerOptions {
runtime: "server" | "client";
request?: unknown;
routeId?: string;
hydration?: Record<string, unknown>;
onMutation?: (mutation: StoreMutation) => void;
}
declare class StoreContainer {
readonly runtime: "server" | "client";
readonly request?: unknown;
readonly routeId?: string;
private readonly instances;
private readonly hydration;
private readonly onMutation?;
private readonly lastMutations;
constructor(options: StoreContainerOptions);
use<S extends object, C extends object, A extends Record<string, StoreFunction>, CS extends object, SS extends object>(definition: StoreDefinition<S, C, A, CS, SS>): Promise<StoreInstance<StoreCombinedState<S, CS, SS>, C, A>>;
serialize(): Record<string, unknown>;
inspect(): Array<{
name: string;
kind: "global" | "page";
state: Readonly<Record<string, unknown>>;
computed: Readonly<Record<string, unknown>>;
lastAction?: string;
changed: string[];
hydrationSource: "server" | "persistence" | "initial";
}>;
hotUpdate<S extends object, C extends object, A extends Record<string, StoreFunction>, CS extends object, SS extends object>(definition: StoreDefinition<S, C, A, CS, SS>): Promise<{
preserved: string[];
reset: string[];
}>;
disposePageStores(): Promise<void>;
dispose(): Promise<void>;
}
declare function createStoreContainer(options: StoreContainerOptions): StoreContainer;
declare function createStoreInstance<S extends object, C extends object, A extends Record<string, StoreFunction>, CS extends object, SS extends object>(definition: StoreDefinition<S, C, A, CS, SS>, options: Omit<StoreContainerOptions, "hydration"> & {
hydration?: unknown;
}): StoreInstance<StoreCombinedState<S, CS, SS>, C, A>;
export { StoreCombinedState, StoreContainer, type StoreContainerOptions, StoreDefinition, StoreFunction, StoreInstance, StoreMutation, createStoreContainer, createStoreInstance, defineStore };
Examples
Copy-ready examples from the installed package documentation.
Install @wrnexus/store
bun add @wrnexus/storeImport @wrnexus/store
import * as store from "@wrnexus/store";