Skip to content
Dashboard

Built-in durability: Introducing Workflow Development Kit

Link to headingTurn async functions into durable workflows

export async function hailRide(requestId: string) {
"use workflow";
const request = await validateRideRequest(requestId);
const trip = await assignDriver(request);
const confirmation = await notifyRider(trip);
const receipt = await createReceipt(trip);
return receipt;
}

This example defines a durable workflow that coordinates multiple steps in a ride-hailing flow. Each step runs independently and can persist, pause, and resume across deploys or failures.

async function validateRideRequest(requestId: string) {
"use step";
// Validate the ride request and get rider details
const response = await fetch(`https://api.example.com/rides/${requestId}`);
// If this fetch fails, the step will automatically retry
if (!response.ok) throw new Error("Ride request validation failed");
const request = await response.json();
return { rider: request.rider, pickup: request.pickup };
}
async function assignDriver(request: any) {
"use step";
// Assign the nearest available driver
}
async function notifyRider(trip: any) {
"use step";
// Notify the rider their driver is on the way
}
async function createReceipt(trip: any) {
"use step";
// Generate a receipt for the trip
}

Each step runs in isolation and automatically retries on failure. In this example, the first step validates a ride request by calling an external API, while later steps assign a driver, notify the rider, and generate a receipt.

import { sleep } from "workflow";
export async function offerLoyaltyReward(riderId: string) {
"use workflow";
// Wait three days before issuing a loyalty credit
await sleep("3d"); // No resources are used during sleep
return { riderId, reward: "Ride Credit" };
}

Some workflows need to wait for hours or days before continuing. This example pauses execution for three days before issuing a loyalty reward to the rider, without consuming resources or losing state.

Link to headingWebhooks: Pause and Resume with External Events

import { createWebhook, fetch } from "workflow";
export async function validatePaymentMethod(rideId: string) {
"use workflow";
const webhook = createWebhook();
// Trigger external payment validation with callback to webhook URL
await fetch("https://api.example-payments.com/validate-method", {
method: "POST",
body: JSON.stringify({ rideId, callback: webhook.url }),
});
// Wait for payment provider to confirm via webhook
const { request } = await webhook;
const confirmation = await request.json();
return { rideId, status: confirmation.status };
}

Webhooks let a workflow pause until data arrives from an external service. Here, the workflow sends a callback URL to a payment provider, waits for validation, then resumes automatically once confirmation is received.

Link to headingReliable, durable, and observable by default

Vercel automatically detects when a function is durable and dynamically provisions the ideal infrastructure to support it in real time.Vercel automatically detects when a function is durable and dynamically provisions the ideal infrastructure to support it in real time.
Vercel automatically detects when a function is durable and dynamically provisions the ideal infrastructure to support it in real time.

Link to headingWorkflows run anywhere with Worlds

Build natural language image search

Use this template to build an AI-powered image search application with automatic description generation and indexing for semantic search.

Deploy now

Link to headingBuilt for systems that need intelligence and reliability

Start building durable workflows

Use familiar JavaScript to build workflows that persist across deploys and crashes. No queues, schedulers, or extra infrastructure required.

Get started