Skip to Content

next-workflow-builder

DevKit AI Builder Template DocumentationMarketplace
CTRL K
Demo
CTRL K
  • DevKit 
  • AI Builder Template 
    • Introduction
    • Getting Started
    • Configuration
    • Plugins
      • Overview
      • HTTP Request
      • Condition
      • Loop
      • Merge
      • Database Query
      • Run Workflow
      • Run Workflows in Sequence
      • Switch
    • Creating Plugins
    • API Reference
    • CLI Reference
    • Components
    • Database
    • Authentication
    • Deployment
    • Architecture
    • Contributing
    • MCP Server
  • Marketplace
  • Introduction
  • Getting Started
  • Configuration
  • Plugins
    • Overview
    • HTTP Request
    • Condition
    • Loop
    • Merge
    • Database Query
    • Run Workflow
    • Run Workflows in Sequence
    • Switch
  • Creating Plugins
  • API Reference
  • CLI Reference
  • Components
  • Database
  • Authentication
  • Deployment
  • Architecture
  • Contributing
  • MCP Server

On This Page

  • Package exports
  • Main export (next-workflow-builder)
  • nextWorkflowBuilder(config?)
  • API export (next-workflow-builder/api)
  • Server exports (next-workflow-builder/server)
  • auth
  • db
  • fetchCredentials(integrationId)
  • generateWorkflowMetadata(props)
  • withStepLogging(input, fn)
  • encrypt(text) / decrypt(text)
  • generateId()
  • getErrorMessage(error) / getErrorMessageAsync(error)
  • Database tables
  • Plugin exports (next-workflow-builder/plugins)
  • registerIntegration(plugin)
  • registerCodegenTemplates(templates)
  • registerOutputDisplayConfigs(configs)
  • Registry query functions
  • Utility functions
  • Client export (next-workflow-builder/client)
  • Types
  • IntegrationPlugin
  • PluginAction
  • ActionConfigField
  • ActionWithFullId
  • OutputField
  • OutputDisplayConfig
  • StepInput
  • NextWorkflowBuilderConfig
  • Built-in API routes
  • Authentication
  • Workflows
  • Executions
  • Integrations
  • API Keys
Question? Give us feedback Edit this page 
DocumentationAPI Reference

API Reference

Package exports

The package provides several entry points:

Import pathDescription
next-workflow-builderNext.js plugin: nextWorkflowBuilder() config wrapper
next-workflow-builder/clientReact components: Layout, WorkflowPage, WorkflowEditor
next-workflow-builder/serverServer-side: auth, db, schema tables, credentials, metadata, logging
next-workflow-builder/apiHTTP route handlers: GET, POST, PUT, PATCH, DELETE, OPTIONS
next-workflow-builder/pluginsPlugin system: registration, registry utilities, types
next-workflow-builder/server/db/schemaDrizzle ORM schema (for drizzle.config.ts)
next-workflow-builder/styles.cssRequired CSS styles

Main export (next-workflow-builder)

import nextWorkflowBuilder from "next-workflow-builder"; import type { NextWorkflowBuilderConfig, WithNextWorkflowBuilder } from "next-workflow-builder";

nextWorkflowBuilder(config?)

The default export. Returns a function that wraps your Next.js config.

const withNextWorkflowBuilder = nextWorkflowBuilder({ authOptions: { /* Better Auth options */ }, debug: true, }); const nextConfig = withNextWorkflowBuilder({ /* Next.js config */ });

Parameters: NextWorkflowBuilderConfig (see Configuration) Returns: (nextConfig: NextConfig) => NextConfig


API export (next-workflow-builder/api)

export { GET, POST, PUT, PATCH, DELETE, OPTIONS } from "next-workflow-builder/api";

Re-export these HTTP method handlers in your catch-all API route (app/api/[[...slug]]/route.ts). They handle all workflow, auth, integration, and API key endpoints.


Server exports (next-workflow-builder/server)

import { auth, db, fetchCredentials, generateWorkflowMetadata, withStepLogging, generateId, encrypt, decrypt, getErrorMessage, getErrorMessageAsync, discoverPlugins, // Database tables users, sessions, accounts, verifications, workflows, integrations, workflowExecutions, workflowExecutionLogs, apiKeys, } from "next-workflow-builder/server"; import type { StepInput, ResultComponentProps } from "next-workflow-builder/server";

auth

The Better Auth instance. Use for session management:

const session = await auth.api.getSession({ headers: request.headers });

db

The Drizzle ORM database instance with the full schema:

const userWorkflows = await db.query.workflows.findMany({ where: eq(workflows.userId, userId), });

fetchCredentials(integrationId)

Fetch and decrypt credentials for an integration. Used in step handlers.

const credentials = await fetchCredentials(input.integrationId);

Parameters: string - Integration ID Returns: Promise<Record<string, string>>

generateWorkflowMetadata(props)

Generate dynamic page metadata for workflow pages. Export as generateMetadata in your catch-all page:

export { generateWorkflowMetadata as generateMetadata } from "next-workflow-builder/server";

withStepLogging(input, fn)

Wrap a step handler function with execution logging for the workflow runs panel.

return withStepLogging(input, () => stepHandler(input, credentials));

Parameters:

  • input - StepInput object
  • fn - () => Promise<T> - The step handler function

Returns: Promise<T>

encrypt(text) / decrypt(text)

Encrypt and decrypt integration credentials stored in the database.

generateId()

Generate a unique nanoid-based identifier for database records.

getErrorMessage(error) / getErrorMessageAsync(error)

Extract a human-readable error message from unknown error types.

Database tables

All Drizzle ORM table schemas are exported directly: users, sessions, accounts, verifications, workflows, integrations, workflowExecutions, workflowExecutionLogs, apiKeys.


Plugin exports (next-workflow-builder/plugins)

import { registerIntegration, registerCodegenTemplates, registerOutputDisplayConfigs, getIntegration, getAllIntegrations, getIntegrationTypes, getAllActions, getActionsByCategory, findActionById, getCodegenTemplate, getOutputDisplayConfig, computeActionId, parseActionId, flattenConfigFields, isFieldGroup, getIntegrationLabels, getIntegrationDescriptions, getSortedIntegrationTypes, getAllDependencies, getDependenciesForActions, getAllEnvVars, getPluginEnvVars, getCredentialMapping, generateAIActionPrompts, } from "next-workflow-builder/plugins";

registerIntegration(plugin)

Register a plugin with the integration registry.

registerIntegration(myPlugin);

Parameters: IntegrationPlugin - The plugin definition object

registerCodegenTemplates(templates)

Register code generation templates. Called from auto-generated lib/codegen-registry.ts.

registerOutputDisplayConfigs(configs)

Register output display configurations. Called from auto-generated lib/output-display-configs.ts.

Registry query functions

FunctionReturnsDescription
getIntegration(type)IntegrationPlugin | undefinedGet a single integration plugin
getAllIntegrations()IntegrationPlugin[]Get all registered integrations
getIntegrationTypes()string[]Get list of all integration type slugs
getAllActions()ActionWithFullId[]Get all actions across integrations
getActionsByCategory()Record<string, ActionWithFullId[]>Get actions grouped by category
findActionById(id)ActionWithFullId | undefinedFind action by full ID or legacy label
getCodegenTemplate(id)string | undefinedGet codegen template for an action
getOutputDisplayConfig(id)OutputDisplayConfig | undefinedGet output display config

Utility functions

FunctionDescription
computeActionId(type, slug)Compute full action ID (e.g. "slack/send-message")
parseActionId(id)Parse action ID into { integration, slug }
flattenConfigFields(fields)Flatten config field groups into flat array
isFieldGroup(field)Type guard for ActionConfigFieldGroup
getAllDependencies()Get all NPM dependencies across integrations
getDependenciesForActions(ids)Get dependencies for specific actions
getAllEnvVars()Get all environment variables across integrations
getPluginEnvVars(plugin)Get env vars for a single plugin
getCredentialMapping(plugin, config)Get credential mapping for a plugin
generateAIActionPrompts()Generate AI prompt section for all actions

Client export (next-workflow-builder/client)

import { Layout, WorkflowPage, WorkflowEditor, isAiGatewayManagedKeysEnabled, isAiGatewayManagedKeysEnabledClient, } from "next-workflow-builder/client";

See Components for detailed component documentation.


Types

IntegrationPlugin

Full plugin definition. See Creating Plugins for field details.

PluginAction

Action definition within a plugin.

ActionConfigField

Config field definition. Can be ActionConfigFieldBase or ActionConfigFieldGroup.

ActionWithFullId

A PluginAction extended with id (full action ID) and integration (integration type).

OutputField

type OutputField = { field: string; description: string; };

OutputDisplayConfig

type OutputDisplayConfig = | { type: "image" | "video" | "url"; field: string } | { type: "component"; component: React.ComponentType<ResultComponentProps> };

StepInput

Base input type for step handlers. Extend this for your step’s specific inputs.

NextWorkflowBuilderConfig

type NextWorkflowBuilderConfig = { debug?: boolean; authOptions?: Record<string, unknown>; };

Built-in API routes

All routes are relative to the /api base path.

Authentication

MethodPathDescription
GET/POST/auth/[...all]Better Auth handler (sign in, sign up, session, etc.)
GET/PATCH/userGet or update current user

Workflows

MethodPathDescription
GET/workflowsList all workflows for the current user
POST/workflows/createCreate a new workflow
GET/POST/workflows/currentGet or set the current active workflow
GET/workflows/[id]Get a specific workflow
PATCH/workflows/[id]Update a workflow
DELETE/workflows/[id]Delete a workflow
POST/workflow/[id]/executeExecute a workflow
GET/workflow/[id]/cronExecute a workflow via Vercel Cron (requires CRON_SECRET bearer token)
POST/workflows/[id]/duplicateDuplicate a workflow
GET/workflows/[id]/codeGet generated code for a workflow
GET/workflows/[id]/downloadDownload workflow as a ZIP file
POST/workflows/[id]/webhookTrigger a workflow via webhook
GET/DELETE/workflows/[id]/executionsList or clear workflow executions

Executions

MethodPathDescription
GET/workflows/executions/[executionId]/statusGet execution status
GET/workflows/executions/[executionId]/logsGet execution logs
POST/workflows/executions/[executionId]/cancelCancel a running execution

Integrations

MethodPathDescription
GET/POST/integrationsList or create integrations
GET/PUT/DELETE/integrations/[id]Get, update, or delete an integration
POST/integrations/testTest integration credentials (before saving)
POST/integrations/[id]/testTest a saved integration’s credentials

API Keys

MethodPathDescription
GET/POST/api-keysList or create API keys
DELETE/api-keys/[keyId]Delete an API key
Last updated on March 12, 2026
Creating PluginsCLI Reference

© 2026 All rights reserved.

Product by David Sanchez