Vercel Workflow

Configure Vercel Workflow and run durable workflows on Vercel.

Use Vercel Workflow when your app already runs on Vercel and you want workflow runs to stay on the same platform.

Before you start

Terminal
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/workflow@main workflow

Configure Vercel

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@vitehub/workflow/nuxt'],
})

If the app is deployed on Vercel, you usually do not need to set workflow.provider. ViteHub detects Vercel automatically and uses the workflow file you defined under src/workflows/ or server/workflows/.

Set workflow.workflow only for the advanced case where you already have a Vercel workflow object and want to pass that object directly instead of using your ViteHub workflow file.

Define a workflow

Create a workflow file for the job you want to run.

server/workflows/publish-draft.ts
export default defineWorkflow(async (input?: { title?: string }, context) => {
  const title = input?.title?.trim() || 'Untitled draft'

  return {
    provider: context?.provider,
    title,
  }
})

Start a workflow run

server/api/workflows/publish.post.ts
import { runWorkflow } from '@vitehub/workflow'

export default defineEventHandler(async () => {
  const run = await runWorkflow('publish-draft', {
    title: 'Ship weekly digest',
  })

  return {
    runId: run.id,
    status: await run.status(),
  }
})

runWorkflow() returns a run handle right away. In this example, the response includes the run id and the current status so you can store the id and check it again later.

Vercel-specific options

Use top-level workflow config only for app-wide integration settings.

OptionUse it for
workflow.workflowPass an existing Vercel workflow object instead of the ViteHub workflow file for that name.

What changes on Vercel

ConcernBehavior
Start behaviorViteHub passes your workflow file, your payload, and any start options to Vercel's start() API.
Run lookupgetWorkflowRun(id) calls Vercel's getRun(id) API.
Shared run methodsEvery run supports id, status(), and stop().
Vercel-only methodsrun.vercel.result() reads the workflow return value when Vercel exposes it. run.native gives you the raw Vercel run object.
Choose Vercel when the rest of the app already deploys on Vercel and you want workflow runs to follow the same platform model.