Install dependencies
Install the required packages:
NestJS with Workflow DevKit requires SWC for compilation. The
@swc/cli and @swc/core packages are peer dependencies.Initialize SWC configuration
Run the Workflow NestJS CLI to set up SWC:This creates a
.swcrc file with the Workflow plugin configured:.swcrc
Configure the Workflow module
Import and configure the Workflow module in your app:The
src/app.module.ts
WorkflowModule.forRoot() method:- Registers the
WorkflowControllerfor handling workflow endpoints - Configures the builder to compile workflows
- Sets up the output directory for workflow bundles
How it works
The NestJS integration:- Module system: Uses NestJS’s module system for dependency injection
- Builder: Compiles workflows during module initialization using
NestLocalBuilder - Controller: Provides a
WorkflowControllerthat handles workflow endpoints:POST /.well-known/workflow/v1/step- Step executionPOST /.well-known/workflow/v1/flow- Workflow executionALL /.well-known/workflow/v1/webhook/:token- Webhook handlingGET /.well-known/workflow/v1/manifest.json- Manifest (whenWORKFLOW_PUBLIC_MANIFEST=1)
- Request conversion: Automatically converts Express/Fastify requests to Web API Request objects
- Build queue: Prevents concurrent builds during module initialization
Example workflow
src/workflows/notification.ts
Triggering workflows
Start workflows from controllers:src/app.controller.ts
Development
Run the development server:Production
Build for production:src/app.module.ts
Configuration options
WorkflowModuleOptions
Next steps
Core Concepts
Learn about workflows and steps
API Reference
View the full NestJS API reference