Installation
Usage
Wrap your Next.js configuration withwithWorkflow to enable workflow functionality:
next.config.js
With Async Config Function
next.config.js
API
withWorkflow(nextConfig, options?)
Wraps your Next.js configuration to add workflow support.
Your Next.js configuration object or async function that returns a configuration.When a function is provided, it receives:
phase: The build phase (e.g.,PHASE_DEVELOPMENT_SERVER)ctx.defaultConfig: Default Next.js configuration
Workflow configuration options.
Workflow-specific settings.
Enable lazy discovery of workflows. When enabled, workflows are discovered on-demand rather than at build time.Sets
WORKFLOW_NEXT_LAZY_DISCOVERY=1 environment variable.Local development configuration.
Port number for the local development server.Sets the
PORT environment variable.Directory for storing workflow data in local development.Default:
.next/workflow-dataConfiguration Examples
Basic Configuration
next.config.js
With Lazy Discovery
next.config.js
Custom Local Development
next.config.js
Runtime Exports
The package also exports runtime utilities:Loader Export
Internal loader for webpack/turbopack integration:How It Works
withWorkflow automatically configures:
- Webpack: Adds a custom loader to transform workflow files
- Turbopack: Configures rules for
.ts,.tsx,.js,.jsx,.mjs,.mts,.cjs,.ctsfiles - Builder: Discovers and builds workflows from
pages/,app/,src/pages/, andsrc/app/directories - Environment: Sets up appropriate world target (local or Vercel)
Supported Next.js Versions
Requires Next.js 13 or higher.Deferred Builder (Next.js 16+)
For Next.js v16.0.0 and above, the integration uses a deferred builder that integrates with Next.js’s experimental deferred entries feature for better performance.Environment Variables
The integration automatically sets these environment variables:WORKFLOW_TARGET_WORLD: Set tolocal(development) orvercel(production)WORKFLOW_LOCAL_DATA_DIR: Directory for local workflow dataPORT: Development server port (if configured)WORKFLOW_NEXT_LAZY_DISCOVERY: Enable lazy workflow discovery