Commiq Docs

Introduction

Introduction

Commiq is a lightweight, command & event driven state management library for TypeScript. The core library has no framework dependencies — React bindings are available separately via @naikidev/commiq-react.

Instead of directly mutating state, you describe what should happen via commands, and the store's handlers decide how the state changes. Handlers can emit events to notify other parts of your application — enabling clean, decoupled architectures.

Key Concepts

ConceptDescription
CommandA request to do something — dispatched via queue()
HandlerA function that processes a command and updates state
EventA notification that something happened — emitted by handlers
StoreHolds state, routes commands to handlers, broadcasts events
Sealed StoreA read-only proxy exposing only state, queue, and streams
Event BusRoutes events between multiple stores

Packages

  • @naikidev/commiq — Core library (framework-agnostic)
  • @naikidev/commiq-react — React bindings (useSelector, useQueue, useEvent, CommiqProvider)
  • @naikidev/commiq-devtools-core — Instrumentation, event timeline, and causality tracking
  • @naikidev/commiq-devtools — Embedded devtools panel for React applications
  • @naikidev/commiq-otel — OpenTelemetry tracing integration

Quick Example

import { createStore, createCommand, sealStore } from "@naikidev/commiq";

const store = createStore({ count: 0 });

store.addCommandHandler("increment", (ctx) => {
  ctx.setState({ count: ctx.state.count + 1 });
});

const sealed = sealStore(store);
sealed.queue(createCommand("increment", undefined));

On this page