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:
pnpm installpnpm --filter input-actions-basic-form-example devEach example’s package.json has its name.
Find an example by feature
Section titled “Find an example by feature”| To see | Look at |
|---|---|
Component-local state with useLocalActions | Basic form, Date form |
A global store with StoreProvider | Global 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/delay | Checkout, Chat and cart, Chat |
Bindings with defineBindings and useBoundActions | Bindings, Chat |
| A specific adapter | Redux, Jotai, MobX, thi.ng/atom; Zustand in Global state |
| Next.js, SSR, Server Actions and the timers package | Real World App |
Local state
Section titled “Local state”Basic form
Section titled “Basic form”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.
Date form
Section titled “Date form”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.
Global store
Section titled “Global store”Global state
Section titled “Global state”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.
Bindings
Section titled “Bindings”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.
Chat and cart
Section titled “Chat and cart”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.
Checkout
Section titled “Checkout”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.
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.
Adapters
Section titled “Adapters”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.
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.
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.
thi.ng/atom
Section titled “thi.ng/atom”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.
Full app
Section titled “Full app”Real World App
Section titled “Real World App”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.