Skip to content

Latest commit

 

History

History
117 lines (77 loc) · 2.7 KB

File metadata and controls

117 lines (77 loc) · 2.7 KB
id installation
title Installation
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:

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

Storage

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

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:

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

const store = inMemoryWorkflowExecutionStore()

For Postgres:

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

const store = createDrizzlePostgresWorkflowStore({ db })

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

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

For Cloudflare D1:

pnpm add @tanstack/workflow-store-cloudflare-d1
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:

pnpm add @tanstack/workflow-netlify

For Cloudflare:

pnpm add @tanstack/workflow-cloudflare

For Railway:

pnpm add @tanstack/workflow-railway

For 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.