GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Workflows

Run long tasks in steps, then check their status and result later with a run id.

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 }
}
server/workflows/onboard-user/01.create-user.ts

One file or folder per workflow

Add a file to server/workflows. Its name is the workflow name.

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.

Choose where runs live

Use Cloudflare, Vercel, or OpenWorkflow with Postgres or SQLite on your own server. Routes stay the same.

Clear error codes

Throw errors with fixed codes that work the same on every host.