Relay keeps multi-stage React flows deterministic by treating every async task as a typed step that the store coordinates.
Each step reports success or failure, the store exposes capability guards, and the helpers (start, next, retry, resume, reset) keep transitions safe even while the UI changes.
- Typed stepping:
createRelaylocks in your config, metadata, success, and error payloads before you register any steps.createRelayStep,StepSuccess, andStepErrorkeep every execution well-typed. - Guarded actions: Derived flags such as
canStart,canNext,canRetry, andcanResumetell you exactly when to call each helper. - Configurable flow: The default config runs the next step automatically (
autoNextExecute: true) unless you opt into manually advancing withexecuteOnNext: true. - Centralized status:
useRelay()exposesstepsState,stepsBase, andisRunningso your UI can render loaders, retries, and confirmations without scatteringuseEffecthooks.
- Define your DTOs (
RelayConfig,RelayStepBase,RelayStepSuccess,RelayStepError). - Call
createRelay("flow-key", config)to lock in your types and optional config overrides. - Build steps with
createRelayStep, pass them toinitialize, and drive the flow withstart,next,retry,resume, orreset. - Use
stepsState+stepsBaseplus the guard booleans fromuseRelay()to build status updates and navigation controls.
Read the full guide at relay.0xhq.com/docs/getting-started and see apps/docs.relay/examples/simple for a working UI.
pnpm add @0xhq/relayWorks in TypeScript-friendly toolchains that understand ESM entry points (Node 18+, Next.js, Vite, Deno, etc.).