Workflow
Write an async function that can outlive its process.
TanStack Workflow records durable execution around ordinary TypeScript so steps, retries, sleeps, signals, and approvals can continue after a worker disappears.
run
order-4832
reserve inventory
completed
manager approval
waiting
release fulfillment
queued
append-only history
- 01
run.started
order-4832
- 02
step.completed
reserve-inventory
- 03
approval.requested
manager-approval
export async function fulfillOrder(input, ctx) {
const reservation = await ctx.step(
'reserve-inventory', () => reserve(input)
)
const approval = await ctx.approve({
title: 'Release fulfillment?'
})
return ctx.step(
'release-fulfillment', () => release(reservation, approval)
)
}
Code is the process
Control flow stays in plain async TypeScript.
Conditionals, loops, variables, and errors remain language features. The workflow context adds durable boundaries only where time, retries, side effects, or external input need to survive beyond the current process.
Time and outside input
Waiting is a stored state, not a worker doing nothing.
A workflow can sleep until later, wait for an external event, or request human approval. Host-delivered signal IDs make retries idempotent, while recorded time and UUID primitives keep decisions deterministic when the function runs again.
history record
wakeAt · replay-safe timestamp
worker
free to stop while waiting
Durability boundary
Bring the runtime and store that fit your application.
The workflow definition is application code. A runtime adapter executes it, and a durable store preserves the append-only history needed for recovery. Current runtimes and adapters are experimental, so deployment and version routing remain explicit choices.
Workflow definition
Versioned TypeScript and stable step IDs
Runtime adapter
Executes, schedules, retries, and receives signals
Durable store
Persists history outside the worker process
Replay skips recorded steps. It does not make arbitrary external side effects exactly once; use idempotent boundaries.
Route existing runs to compatible workflow versions when definitions evolve.
Partners
Sponsors get special perks like private discord channels, priority issue requests, and direct support!