UNPKG

workflow

Version:

Workflow SDK - Build durable, resilient, and observable workflows

59 lines (44 loc) • 2.68 kB
--- title: "workflow/nitro" description: Nitro module for automatic workflow bundling and route registration. type: overview summary: Explore the Nitro module that enables workflow directive transformation in Nitro apps. related: - /docs/getting-started/nitro --- Nitro integration for Workflow SDK. The `workflow/nitro` entry point's default export is a [Nitro module](https://v3.nitro.build/guide/modules) — it has no callable API. You enable it by adding it to the `modules` array of your Nitro config and configure it via the `workflow` key. ## Usage ```typescript title="nitro.config.ts" lineNumbers import { defineConfig } from "nitro"; export default defineConfig({ serverDir: "./server", modules: ["workflow/nitro"], // [!code highlight] }); ``` When enabled, the module: - Transforms `"use workflow"` and `"use step"` directives during bundling. - Builds the workflow, step, and webhook bundles, and rebuilds them on file changes in development. - Registers the workflow runtime routes under `/.well-known/workflow/v1/`. - Serves a redirect to the local observability dashboard at `/_workflow` in development. - Configures Vercel function rules (queue triggers and `maxDuration`) for the workflow routes when deploying to Vercel. - Uses Nitro's `workspaceDir` as the workflow project root so monorepo apps can import sibling workspace packages without extra workflow config. ## Module Options Options are read from the `workflow` key of your Nitro config. The option type is exported as `ModuleOptions`: ```typescript title="nitro.config.ts" lineNumbers import { defineConfig } from "nitro"; import type { ModuleOptions } from "workflow/nitro"; // [!code highlight] const workflow: ModuleOptions = { runtime: "nodejs22.x", }; export default defineConfig({ modules: ["workflow/nitro"], workflow, // [!code highlight] }); ``` | Option | Type | Default | Description | | --- | --- | --- | --- | | `dirs` | `string[]` | — | Directories to scan for workflows and steps. By default, the `workflows/` directory is scanned from the project root and all layer source directories. | | `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. | | `runtime` | `string` | — | Node.js runtime version for Vercel Functions (e.g. `'nodejs22.x'`, `'nodejs24.x'`). Only applies when deploying to Vercel. | ## Vite-based Nitro If you use Nitro through its Vite plugin (`nitro/vite`) instead of a standalone `nitro.config.ts`, use the [`workflow/vite`](/docs/api-reference/workflow-vite) entry point, which wraps this module as a Vite plugin and accepts the same `ModuleOptions`.