Getting Started

Installation

sh
pnpm add @tanstack/workflow-core
pnpm add @tanstack/workflow-core

Install zod or another Standard Schema library if you use input / output / state / waitForEvent({ schema }) validation.

Runtime

For registered workflows, schedules, timers, leases, and host sweeps:

sh
pnpm add @tanstack/workflow-core @tanstack/workflow-runtime
pnpm add @tanstack/workflow-core @tanstack/workflow-runtime

Storage

Run state lives in a RunStore. Ships with one in-memory implementation:

ts
import { inMemoryRunStore } from '@tanstack/workflow-core'
const runStore = inMemoryRunStore({ ttl: 60 * 60 * 1000 }) // 1h, paused runs exempt
import { inMemoryRunStore } from '@tanstack/workflow-core'
const runStore = inMemoryRunStore({ ttl: 60 * 60 * 1000 }) // 1h, paused runs exempt

The production runtime uses a richer WorkflowExecutionStore. For local tests:

ts
import { inMemoryWorkflowExecutionStore } from '@tanstack/workflow-runtime'

const store = inMemoryWorkflowExecutionStore()
import { inMemoryWorkflowExecutionStore } from '@tanstack/workflow-runtime'

const store = inMemoryWorkflowExecutionStore()

For Postgres:

sh
pnpm add @tanstack/workflow-store-drizzle-postgres drizzle-orm pg
pnpm add @tanstack/workflow-store-drizzle-postgres drizzle-orm pg
ts
import { createDrizzlePostgresWorkflowStore } from '@tanstack/workflow-store-drizzle-postgres'

const store = createDrizzlePostgresWorkflowStore({ db })
import { createDrizzlePostgresWorkflowStore } from '@tanstack/workflow-store-drizzle-postgres'

const store = createDrizzlePostgresWorkflowStore({ db })

Apply the package-owned store migration during setup/deploy:

sh
psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql
psql "$DATABASE_URL" -f node_modules/@tanstack/workflow-store-drizzle-postgres/migrations/0000_workflow_store.sql

For Cloudflare D1:

sh
pnpm add @tanstack/workflow-store-cloudflare-d1
pnpm add @tanstack/workflow-store-cloudflare-d1
ts
import { createCloudflareD1WorkflowStore } from '@tanstack/workflow-store-cloudflare-d1'

const store = createCloudflareD1WorkflowStore({ db: env.WORKFLOW_DB })
import { createCloudflareD1WorkflowStore } from '@tanstack/workflow-store-cloudflare-d1'

const store = createCloudflareD1WorkflowStore({ db: env.WORKFLOW_DB })

Copy or reference the package-owned SQL artifact from node_modules/@tanstack/workflow-store-cloudflare-d1/migrations/0000_workflow_store.sql in your D1 migration flow.

Server framework

Engine is framework-agnostic. Two entry points:

  • runWorkflow({...}) — long-lived process or SSE handler. Returns AsyncIterable<WorkflowEvent>.
  • handleWorkflowWebhook({...}) — stateless one-invocation drive. Returns the appended events.

Use either with TanStack Start server functions, Hono, Express, Cloudflare Workers, AWS Lambda — anything that can receive an HTTP request.

The runtime adds:

  • runtime.startRun(...)
  • runtime.deliverSignal(...)
  • runtime.deliverApproval(...)
  • runtime.sweep(...)

Host adapters

For Netlify:

sh
pnpm add @tanstack/workflow-netlify
pnpm add @tanstack/workflow-netlify

For Cloudflare:

sh
pnpm add @tanstack/workflow-cloudflare
pnpm add @tanstack/workflow-cloudflare

For Railway:

sh
pnpm add @tanstack/workflow-railway
pnpm add @tanstack/workflow-railway

For Vercel:

sh
pnpm add @tanstack/workflow-vercel
pnpm add @tanstack/workflow-vercel

See the Deployment guide for full setup.

Framework bindings

None yet. React / Solid / Vue / Svelte hooks (useWorkflow) ship in follow-up packages.