Back to Home
qortex-store-react
React State Hooks

qortex-store-react

React hooks for qortex-store with selector support. Optimized for minimal re-renders and developer ergonomics with createUseStore.

npm install qortex-store-react

Quick Start

import { createStore, createUseStore } from 'qortex-store-react';
// 1. Create a store
const counterStore = createStore((set, get) => ({
count: 0,
increment: () => set({ count: get().count + 1 }),
}));
// 2. Create a specialized hook (Recommended)
export const useCounter = createUseStore(counterStore);
// 3. Use in React components
function Counter() {
const count = useCounter((s) => s.count);
const increment = useCounter((s) => s.increment);
return <button onClick={increment}>Count: {count}</button>;
}

Features

Selector Support

Pick only the state slices you need

Concurrent Safe

Fully compatible with React 18+ concurrent features

Bound Hooks

Create specialized hooks with createUseStore for better ergonomics

Custom Equality

Bring your own equality function for object selectors

TypeScript First

Full generic type inference out of the box

Auto Cleanup

Unsubscribes automatically on unmount

API Reference

ParameterTypeDescription
storeStore<T>A store created with createStore
selector?(state: T) => UPicks a state slice (defaults to identity)
equalityFn?(a: U, b: U) => booleanCustom equality (defaults to Object.is)

Tiny Bundle Size

Lightweight and optimized for performance.

~0.3KBmin + gzip

0.3KB / 10KB Performance Budget

Minified Size0.8KB
Dependencies1
Tree Shaking
Supported

Ready to get started?

npm install qortex-store-react

Back to Home