Skip to main content
This guide shows you how to install Workflow DevKit in a NestJS project.
1

Install dependencies

Install the required packages:
NestJS with Workflow DevKit requires SWC for compilation. The @swc/cli and @swc/core packages are peer dependencies.
2

Initialize SWC configuration

Run the Workflow NestJS CLI to set up SWC:
This creates a .swcrc file with the Workflow plugin configured:
.swcrc
3

Configure the Workflow module

Import and configure the Workflow module in your app:
src/app.module.ts
The WorkflowModule.forRoot() method:
  • Registers the WorkflowController for handling workflow endpoints
  • Configures the builder to compile workflows
  • Sets up the output directory for workflow bundles
4

Update NestJS CLI config

Configure NestJS to use SWC for building:
nest-cli.json
5

Enable TypeScript support (Optional)

Add the Workflow TypeScript plugin to your tsconfig.json for IntelliSense:
tsconfig.json

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 WorkflowController that handles workflow endpoints:
    • POST /.well-known/workflow/v1/step - Step execution
    • POST /.well-known/workflow/v1/flow - Workflow execution
    • ALL /.well-known/workflow/v1/webhook/:token - Webhook handling
    • GET /.well-known/workflow/v1/manifest.json - Manifest (when WORKFLOW_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:
Trigger a workflow:

Production

Build for production:
Optionally skip workflow builds in production if workflows are pre-built:
src/app.module.ts

Configuration options

WorkflowModuleOptions

Next steps

Core Concepts

Learn about workflows and steps

API Reference

View the full NestJS API reference