Workflow SDK - Make any TypeScript Function Durable (original) (raw)
use workflow brings durability, reliability, and observability to async JavaScript. Build apps and AI Agents that can suspend, resume, and maintain state with ease.
Reliability-as-code
Move from hand-rolled queues and custom retries to durable, resumable code with simple directives.
export async function welcome(userId: string) {
"use workflow";
const user = await getUser(userId);
const { subject, body } = await generateEmail({
name: user.name, plan: user.plan
});
const { status } = await sendEmail({
to: user.email,
subject,
body,
});
return { status, subject, body };
}Queueing the getUser step...
Effortless setup
With a simple declarative API to define and use your workflows.
Universally Compatible
Works with the frameworks you already use with more coming soon.
Next.jsViteAstroAstroExpressFastifyHonoNitroNuxtSvelteKitNestJSTanStack
Deep integration with AI SDK. Use familiar AI SDK patterns, plus durability, observability, and retries so agents stay reliable in production.
Durable agents by default. High-performance streaming, persistence, and resumable runs work out of the box. No infrastructure setup required.
Inspect every run end‑to‑end.
Observability is built into the SDK and works anywhere you run it. When using workflow on Vercel, observability is built into the Vercel dashboard with no configuration or storage.
Build anything with
Build reliable, long-running processes with automatic retries, state persistence, and observability built in.
export async function aiAgentWorkflow(query: string) {
"use workflow";
// Step 1: Generate initial response
const response = await generateResponse(query);
// Step 2: Research and validate
const facts = await researchFacts(response);
// Step 3: Refine with fact-checking
const refined = await refineWithFacts(response, facts);
return { response: refined, sources: facts };
}Get started
See Workflow SDK in action with one of the example templates.