Skip to main content
Workflows run inside Cloudflare Durable Objects. Setup requires three things: defining your workflows and exporting the generated class, re-exporting that class from your worker entry point, and declaring the Durable Object binding in wrangler.jsonc.
1

Define and export your workflows

Create a file (e.g. workflows.ts) that defines your workflows and calls createDurableWorkflows. This generates the Workflows Durable Object class and the typed WorkflowClient.
import { Effect } from "effect";
import { Workflow, Backoff, createDurableWorkflows } from "@durable-effect/workflow";

const processOrderWorkflow = Workflow.make((orderId: string) =>
  Effect.gen(function* () {
    const order = yield* Workflow.step({
      name: "Fetch order",
      execute: fetchOrder(orderId),
    });

    yield* Workflow.sleep("3 seconds");

    yield* Workflow.step({
      name: "Process payment",
      execute: processPayment(order),
      retry: {
        maxAttempts: 5,
        delay: Backoff.exponential({ base: "1 second", max: "60 seconds" }),
      },
    });

    yield* Workflow.step({
      name: "Send confirmation",
      execute: sendEmail(order.email),
    });
  })
);

const workflows = {
  processOrder: processOrderWorkflow,
} as const;

export const { Workflows, WorkflowClient } = createDurableWorkflows(workflows);
The key name in the workflows object ("processOrder") is what clients use to reference the workflow. The WorkflowClient exported here is already typed to those workflow names and their input types.
2

Export Workflows from your worker entry point

Cloudflare requires Durable Object classes to be exported from the worker’s main entry file. Re-export the Workflows class there:
import { Workflows } from "./workflows";

export { Workflows };

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    // Your fetch handler
  },
};
3

Configure wrangler.jsonc

Add a durable_objects binding and a migration entry to your wrangler.jsonc:
{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2025-11-28",

  "durable_objects": {
    "bindings": [
      {
        "name": "WORKFLOWS",
        "class_name": "Workflows"
      }
    ]
  },

  "migrations": [
    {
      "tag": "v1",
      "new_classes": ["Workflows"]
    }
  ]
}
The name field ("WORKFLOWS") is the binding name you’ll use in your Env type and when creating a client: WorkflowClient.fromBinding(env.WORKFLOWS).
The migrations array is required by Cloudflare for Durable Objects. If you don’t include it, the binding will fail to deploy.

Next: using the client

Once the worker is deployed, use WorkflowClient to start and manage workflow instances. See Client.

Build docs developers (and LLMs) love