r/javascript • u/Glittering_Goose8695 • Apr 02 '26
AskJS [AskJS] State machines feel heavy for UI flows. What are people using?
For UI flows that are not strictly linear (onboarding, checkouts, eligibility flows, etc.), I often see logic distributed across multiple places:
• conditionals in components
• flags in state
• effects triggering navigation
• validation logic duplicated per stepState machines provide a formal model, but in practice they can feel heavy for teams that mainly need to describe a flow graph.
I’m curious what abstractions people are using in real projects.
For example:
• multi-path onboarding
• flows with loops (retry / corrections)
• resumable progress
• feature-dependent steps
• flows spanning multiple screens
Are amost teams:
• relying on router logic?
• building custom hooks?
• using state machines?
• something else?Interested in hearing what has worked well in production.
2
u/Greckooo Apr 02 '26
Used xstate with xstate react in the past with a fair amount of success but you do write an awful lot of code for it. I remember the state machine alone was around 800 files for a 7 step flow
1
u/25_vijay May 16 '26
The sweet spot usually feels like explicit flow graphs with simple transition rules instead of fully formal state machine frameworks unless the domain is genuinely complex.
1
u/[deleted] Apr 06 '26
[removed] — view removed comment