Skip to content

Examples

The repository has twelve example apps. Each one has a README, lint and tests. StackBlitz opens the example in your browser, installed from npm at the latest release. Source is the example on GitHub.

To run one locally, clone the repository, then from its root:

Terminal window
pnpm install
pnpm --filter input-actions-basic-form-example dev

Each example’s package.json has its name.

To seeLook at
Component-local state with useLocalActionsBasic form, Date form
A global store with StoreProviderGlobal state, Chat and cart
Async strategies (prevent, cancel, debounce, queue, allow)Chat uses all five; Basic form starts with two
State machines: invariants, onEnter, machine/delayCheckout, Chat and cart, Chat
Bindings with defineBindings and useBoundActionsBindings, Chat
A specific adapterRedux, Jotai, MobX, thi.ng/atom; Zustand in Global state
Next.js, SSR, Server Actions and the timers packageReal World App

A form on useLocalActions, with no store. Fields, checkboxes, counters and a tag list are all action tuples. Async work uses two strategies: prevent for submit and email validation, so a second click or keystroke can’t start a duplicate request, and debounce for auto-save.

StackBlitz · Source

The validation form from Christian Johansen’s Stateless, data-driven UIs, rebuilt in TypeScript. All state sits in one useLocalActions call, components only render props, and one pure prepareUIData(state) function turns state into those props, cross-field validation included.

StackBlitz · Source

A profile form, shopping cart and todo list on one store, with a switch between the Simple, Redux and Zustand stores that keeps the current state. The components don’t change when the store does.

StackBlitz · Source

The same todo app twice, side by side on one store. The left column writes action tuples inline in JSX; the right registers its behavior once with defineBindings and looks it up with useBoundActions. Changes on either side show on both.

StackBlitz · Source

Two state machines in one store: a chat that goes idle → sending → idle and a cart that runs from browsing to a confirmed order. Async handlers return successActions that put the result into the app’s own state, the cart renders one view per machine mode, and the message composer keeps its draft in local state.

StackBlitz · Source

A six-step checkout driven by one state machine on Redux. Invariants block a step until the previous one is complete, onEnter fetches shipping rates, calculates tax and charges the card, the charge’s onSuccess and onError move the machine on, and machine/delay returns to the cart five seconds after confirmation. The checkout guide builds it step by step.

StackBlitz · Source

A mocked real-time chat that uses most of the library. A connection machine moves between disconnected, connecting, connected and reconnecting, and flushes queued messages on reconnect. All five async strategies appear: prevent to connect, queue to send, allow for history, debounce for search, and cancel to drop a pending search when you switch channels. Behavior is registered as bindings, including ones whose handlers depend on the connection’s mode.

StackBlitz · Source

A small project manager on Redux Toolkit. Every tuple shows up in the Redux DevTools extension as one action, components subscribe to narrow slices, and a DevTools tab runs actions typed in as JSON.

StackBlitz · Source

One Jotai store shared by input-actions and Jotai’s own hooks. Profile data goes through action tuples, while theme and language are atomWithStorage atoms that persist to localStorage.

StackBlitz · Source

A todo list on the MobX adapter. Components dispatch tuples as usual, while MobX’s autorun keeps the tab title in sync and reaction writes a change log, both observing the same state without mobx-react.

StackBlitz · Source

Undo and redo for free: the store wraps @thi.ng/atom’s History, so every dispatch is an undo step and an action/batch undoes as one.

StackBlitz · Source

The Cypress Real World App rebuilt on Next.js 16’s App Router. Server components fetch data and seed the store with HydrateStore, every write is a Server Action called from an async handler, and transaction times use the timers package. It also runs the lint plugin over its action paths. The Next.js guide explains the setup.

Source