Installation
Usage
Add the workflow module to your Nitro configuration:nitro.config.ts
API
Module Options
Configure the Nitro module via theworkflow option in your Nitro config:
nitro.config.ts
Directories to scan for workflows and steps.By default, the
workflows/ directory will be scanned from root and all layer source directories.Enable workflow TypeScript plugin in generated
tsconfig.json.Default: falseNode.js runtime version for Vercel Functions.Examples:
"nodejs22.x""nodejs24.x"
Configuration Examples
Basic Configuration
nitro.config.ts
Custom Directories
nitro.config.ts
Enable TypeScript Plugin
nitro.config.ts
Vercel Runtime Configuration
nitro.config.ts
How It Works
Development Mode
- Transform Plugin: Adds
workflowTransformPluginat the beginning of Rollup plugins - Externalization: Externalizes
.nitro/workflowdirectory to prevent dev reloads - Build Hook: Runs
LocalBuilderduringbuild:beforehook - HMR: Hooks into
dev:reloadto rebuild workflows on file changes - Virtual Handlers: Creates virtual route handlers for workflow endpoints
Production (Non-Vercel)
- Build: Generates workflow bundles via
LocalBuilder - Routes: Creates handlers for:
/.well-known/workflow/v1/webhook/:token/.well-known/workflow/v1/step/.well-known/workflow/v1/flow/.well-known/workflow/v1/manifest.json(whenWORKFLOW_PUBLIC_MANIFEST=1)
Production (Vercel)
- Vercel Builder: Runs
VercelBuilderduringcompiledhook - Build Output API: Generates Vercel Build Output API compatible functions
- Preset Detection: Automatically detected via
nitro.options.preset === 'vercel'
Generated Routes
The module creates the following API routes:POST /.well-known/workflow/v1/flow- Workflow executionPOST /.well-known/workflow/v1/step- Step executionPOST /.well-known/workflow/v1/webhook/:token- Webhook handlerGET /.well-known/workflow/v1/manifest.json- Workflow manifest (optional)
Manifest Handling
Development
Manifest is read from disk at request time usingreadFileSync.
Production
Manifest content is inlined into the handler during build viawriteManifestHandler(), called after the builder generates the manifest.
To expose the manifest endpoint, set:
Nitro Version Compatibility
Supports both Nitro v2 (legacy) and Nitro v3+:- Nitro v2: Uses
fromWebHandlerfromh3to wrap handlers - Nitro v3+: Uses native web handlers directly
nitro.routing property.
TypeScript Plugin
Whenworkflow.typescriptPlugin: true, adds the workflow TypeScript plugin to tsconfig.json:
Build Directory Structure
Exclusions
The transform plugin excludes the.nitro/workflow directory from re-transformation to prevent issues with bundler variable renaming.