Installation
Usage
Import the package in yoursvelte.config.js to enable workflow functionality:
svelte.config.js
svelte.config.js
API
workflowPlugin()
Returns an array of Vite plugins for workflow support in SvelteKit.
Takes no arguments.
Configuration Example
svelte.config.js
How It Works
Top-Level Build
The package executes a top-level build when imported:Vite Plugins
workflowPlugin() returns an array of three plugins:
workflowTransformPlugin(from@workflow/rollup): Transforms workflow directivesworkflow:sveltekit: Named marker pluginworkflowHotUpdatePlugin(from@workflow/vite): Enables HMR for workflow files
Vercel Adapter Support
When using@sveltejs/adapter-vercel, the integration:
- Detects Vercel deployment via
VERCEL_DEPLOYMENT_ID - Patches
.vc-config.jsonfiles for workflow functions - Configures experimental triggers for queue-based execution
Queue Configuration
For/.well-known/workflow/v1/flow.func:
/.well-known/workflow/v1/step.func:
Build Process
- Import-Time: Runs
SvelteKitBuilder.build()to create workflow entries - Development: Watches for changes and rebuilds via HMR
- Vercel Build: On
beforeExit, patches Vercel function configs with queue triggers
Builder
UsesSvelteKitBuilder internally, which:
- Discovers workflows in your SvelteKit project
- Generates route handlers
- Creates workflow bundles
- Integrates with SvelteKit’s routing system
Build Queue
UsescreateBuildQueue() from @workflow/builders to prevent concurrent builds during development.
Generated Routes
The integration creates SvelteKit routes at:/.well-known/workflow/v1/flow- Workflow execution/.well-known/workflow/v1/step- Step execution/.well-known/workflow/v1/webhook/:token- Webhook handler
Vercel Function Patching
ThebeforeExit hook:
- Checks for
VERCEL_DEPLOYMENT_ID - Un-symlinks workflow function directories
- Copies function files from shared location
- Patches
.vc-config.jsonwith queue triggers