Installation
Usage
Add the workflow integration to your Astro configuration:astro.config.mjs
API
workflow()
Astro integration that provides workflow functionality.
Takes no arguments and returns an Astro integration object.
Configuration Example
astro.config.mjs
How It Works
The integration automatically:-
Local Development:
- Builds workflows during
astro:config:setuphook - Adds Vite plugins for workflow transformation and hot module replacement
- Watches for workflow file changes and rebuilds automatically
- Builds workflows during
-
Production (Non-Vercel):
- Uses
LocalBuilderto generate workflow bundles - Creates routes at
.well-known/workflow/v1/
- Uses
-
Vercel Deployment:
- Uses
VercelBuilderduringastro:build:donehook - Generates Vercel Build Output API compatible functions
- Uses
Generated Routes
The integration creates the following API routes:/.well-known/workflow/v1/flow- Workflow execution endpoint/.well-known/workflow/v1/step- Step execution endpoint/.well-known/workflow/v1/webhook/:token- Webhook endpoint/.well-known/workflow/v1/manifest.json- Workflow manifest (whenWORKFLOW_PUBLIC_MANIFEST=1)
Vite Plugins
The integration adds these Vite plugins:workflowTransformPlugin(from@workflow/rollup): Transforms workflow directivesworkflowHotUpdatePlugin(from@workflow/vite): Enables HMR for workflow files
Environment Detection
Automatically detects Vercel deployments viaVERCEL_DEPLOYMENT_ID environment variable and uses the appropriate builder.
Build Queue
UsescreateBuildQueue() from @workflow/builders to prevent concurrent builds during development.
Error Handling
Build errors during config setup are logged and re-thrown to properly propagate to Astro, allowing for better debugging of:- Invalid workflow files
- Missing dependencies
- Configuration issues