Skip to content

machina

Focused finite state machines for JavaScript and TypeScript. States in, states out.

TypeScript-First

Written in TypeScript from the ground up. Full type inference for states, inputs, and transitions.

Hierarchical States

Nest FSMs as child states with automatic input bubbling and delegation between parent and child machines.

Behavioral FSMs

Define behavior once, apply it to n-number of independent clients with zero additional overhead.

Minimal Ceremony

Define states, handle inputs, transition. No generics gymnastics. Just FSMs that solve your problem and get out of your way.

Deferred Inputs

Queue inputs that arrive before a state is ready to handle them. Replay automatically on transition.

Lifecycle Hooks + Events

Fine-grained hooks for enter, exit, and transition events. Subscribe to exactly what you need.

Static Analysis

Catch unreachable states, infinite _onEnter loops, and missing handlers at dev time with machina-inspect and the ESLint plugin.