Skip to content

input-actions

Stateless, data-driven state management for React. Every state change is a tuple, not a callback.

If you’ve read either of these articles and wondered what a TypeScript-React take looks like, this library is it:

Components are visual building blocks that take data and render. State lives in one place. Every state change is a tuple a small executor interprets. UI props are pure derivations from state.

Actions as data

['action/save', ['user', 'name'], 'Alex'] — a value, not a callback. Inspect, log, replay, batch.

Any store

A built-in store, or an adapter for Redux, Zustand, Jotai, thi.ng or MobX. Same action vocabulary on all six. Pick what fits.

Async with strategies

prevent, cancel, queue, debounce, allow — concurrency control as part of the action data.

Built-in state machines

Finite state machines with validated transitions, onEnter/onExit hooks, and sequence/retry primitives.

Action bindings

Hoist behaviour out of JSX into a typed registry. Optional. Components freely mix inline and bindings.

Local + global parity

useLocalActions is component-scoped. StoreProvider is global. Same action vocabulary, swap freely.

import { useLocalActions } from '@input-actions/core';
function Counter() {
const { state, actions } = useLocalActions({ count: 0 });
return (
<>
<button onClick={actions(['action/decrement', ['count']])}>−</button>
<span>{state.count}</span>
<button onClick={actions(['action/increment', ['count']])}>+</button>
</>
);
}

actions(...) turns a tuple into an event handler. The interesting thing is what goes into it: a data tuple a small executor interprets.

See the live, inspectable demo →