Back to Home
qortex-store
State Management

qortex-store

A tiny, type-safe state management library. Framework-agnostic core that works anywhere — Node, browser, vanilla JS. Zero dependencies.

npm install qortex-store

Quick Start

import { createStore } from 'qortex-store';
// Create a store with state and actions
const counterStore = createStore((set, get) => ({
count: 0,
increment: () => set({ count: get().count + 1 }),
decrement: () => set((s) => ({ count: s.count - 1 })),
reset: () => set({ count: 0 }),
}));
// Read state
counterStore.get().count; // 0
// Update state
counterStore.get().increment();
counterStore.get().count; // 1
// Subscribe to changes
const unsub = counterStore.subscribe((state, prev) => {
console.log(prev.count, '→', state.count);
});

Features

Tiny Bundle

Zero runtime dependencies, minimal overhead

Type-Safe

Full TypeScript generics and inference

Framework-Agnostic

Works anywhere — Node, browser, vanilla JS

Shallow Merge

set shallow-merges by default, or replace entirely

Subscribe / Unsubscribe

Listen for state changes with cleanup

Actions Pattern

Define actions alongside state in the initializer

API Reference

MethodDescription
createStore(init)Create a new store with initial state and actions
get()Read the current state snapshot
set(partial, replace?)Update state (merge or replace)
subscribe(listener)Listen for changes, returns unsubscribe fn
destroy()Clear listeners and reset to initial state

Tiny Bundle Size

Lightweight and optimized for performance.

~0.5KBmin + gzip

0.5KB / 10KB Performance Budget

Minified Size1.2KB
Dependencies0
Tree Shaking
Supported

Ready to get started?

npm install qortex-store

Back to Home