Make any TypeScript Function Durable

use workflow brings durability, reliability, and observability to async JavaScript. Build apps and AI Agents that can suspend, resume, and maintain state with ease.

Get Started
npm i workflow

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.

Creating a workflow

import { sleep } from "workflow";
import {
  createUser,
  sendWelcomeEmail,
  sendOneWeekCheckInEmail
} from "./steps"

export async function userSignup(email) {
  "use workflow";

  // Create the user and send the welcome email
  const user = await createUser(email);
  await sendWelcomeEmail(email);

  // Pause for 7 days
  // without consuming any resources
  await sleep("7 days");
  await sendOneWeekCheckInEmail(email);

  return { userId: user.id, status: "done" };
}

Defining steps

import { Resend } from 'resend';
import { FatalError } from 'workflow'; 

export async function sendWelcomeEmail(email) {
  "use step"

  const resend = new Resend('YOUR_API_KEY');

  const resp = await resend.emails.send({
    from: 'Acme <onboarding@resend.dev>',
    to: [email],
    subject: 'Welcome!',
    html: `Thanks for joining Acme.`,
  });

  if (resp.error) {
    throw new FatalError(resp.error.message);
  }
};

// Other steps...

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.

When deploying workflow on Vercel, deep workflow observability is built into the Vercel dashboard with no configuration or storage.

Zero infrastructure management. Fluid compute, serverless functions, queues and persistence work out of the box.

Deploy confidently. Running workflows continue on their original version while new executions use the latest code.

VGxkwTd46Preview
Building
30s
GFsdgf33wProduction
Ready
56s
REsdf2dsxPreview
Ready
49s
LDDgfrT21Production
Ready
59s

No timeout limits. Write long-running workflows without worrying about execution limits.

Pay for what you use. Only pay for actual execution time, not idle resources.

10s
idle
10s
idle
10s

Run anywhere, no lock‑in

The same code runs locally on your laptop, in Docker, on Vercel or any other cloud. Open source and portable by design.

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 };
}

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 };
}

Create your first workflow today.

Get started