Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/iDevRanjan/nexus-store/llms.txt

Use this file to discover all available pages before exploring further.

NexusStore is a minimal, framework-aligned state management solution for React applications. It gives you a global store factory, a fine-grained subscription hook built on useSyncExternalStore, and optional Immer integration for painless nested-state mutations — all without any external runtime dependencies.

Quickstart

Build your first NexusStore-powered React component in under five minutes.

Core Concepts

Understand stores, selectors, and state updates from first principles.

API Reference

Full signatures and parameter docs for every exported function.

Advanced Patterns

Immer integration, batch updates, selector optimization, and custom hooks.

Why NexusStore?

NexusStore was designed to be the smallest possible abstraction that still solves the hard problems in React state management: unnecessary re-renders, tangled update logic, and boilerplate-heavy store setup.

Zero Dependencies

The core has no runtime dependencies. Add Immer only when you need it.

Surgical Re-renders

Selector subscriptions ensure a component re-renders only when its slice of state changes.

Concurrent-mode Safe

Built on React’s useSyncExternalStore — fully compatible with React 18+ concurrent features.

Immer-ready

Wrap any store with immer() to unlock mutation-style updates for deeply nested objects and arrays.

Atomic Batch Updates

Use setMultiple to update multiple keys in a single render cycle — no extra renders.

Simple Architecture

Three files, three exports. Easy to learn, easy to debug, easy to extend.

How It Works

1

Create a store

Call createStore with your initial state object outside any component.
store.js
import { createStore } from './NexusStore/core';

export const countStore = createStore({ count: 0 });
2

Subscribe in a component

Use the useStore hook with a selector to read — and reactively update — only the slice you need.
Counter.jsx
import { useStore } from './NexusStore/useStore';
import { countStore } from './store';

export default function Counter() {
  const count = useStore(countStore, (state) => state.count);
  return <p>{count}</p>;
}
3

Update state

Call setState from anywhere — event handlers, async callbacks, or other components.
countStore.setState(
  (keys) => keys.count,
  (current) => current + 1,
);
4

Scale with multiple stores and custom hooks

Split state by domain, wrap stores with Immer for nested updates, and expose clean custom hooks for each domain.
hooks.js
import { useStore } from './NexusStore/useStore';
import { authStore, themeStore } from './store';

export const useAuthStore  = (sel) => useStore(authStore, sel);
export const useThemeStore = (sel) => useStore(themeStore, sel);
NexusStore ships as source files you copy into your project. There is no npm package — see Installation for setup instructions.

Build docs developers (and LLMs) love