Vercel Workflow
Use Vercel Workflow when your app already runs on Vercel and you want workflow runs to stay on the same platform.
Before you start
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/workflow@main workflow
Configure Vercel
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.
export default defineWorkflow(async (input?: { title?: string }, context) => {
const title = input?.title?.trim() || 'Untitled draft'
return {
provider: context?.provider,
title,
}
})
Start a workflow run
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.
| Option | Use it for |
|---|---|
workflow.workflow | Pass an existing Vercel workflow object instead of the ViteHub workflow file for that name. |
What changes on Vercel
| Concern | Behavior |
|---|---|
| Start behavior | ViteHub passes your workflow file, your payload, and any start options to Vercel's start() API. |
| Run lookup | getWorkflowRun(id) calls Vercel's getRun(id) API. |
| Shared run methods | Every run supports id, status(), and stop(). |
| Vercel-only methods | run.vercel.result() reads the workflow return value when Vercel exposes it. run.native gives you the raw Vercel run object. |