Workflows
Run long tasks in steps, then check their status and result later with a run id.
Deploys on
server/workflows/onboard-user/01.create-user.ts
// Each numbered file in this folder is a step. The steps run
// in order, and each step gets the result of the step before.
// Step 1: create the user
export default async function createUser(input: {
email: string
}) {
// Save the user in your database here
const id = `user:${input.email}`
return { id, email: input.email }
}Split work into steps
Put numbered files in a workflow folder so durable hosts can retry failed steps.
Start now, check later
startWorkflow() starts a run and returns its ID. Your route does not wait for the work.Status and result
getWorkflowRun() returns the status, whether queued, running, completed, or failed, and the result.