Flowlib
Reference

Configuration

All options for flowlib.config.ts.

The configuration object is passed to createFlowlibRouter() (Express), FlowlibModule.forRoot() (NestJS), or createFlowlibHandler() (Next.js). It is also read directly by <Flowlib config={...} /> on the frontend for fields like apiPath, frontendPath, theme, and plugins. Use defineConfig() from @flowlib/core for type inference.

flowlib.config.ts
import { defineConfig } from '@flowlib/core';

export const flowlibConfig = defineConfig({
  database: { ... },
  apiPath: '/api/flowlib',   // backend mount path
  frontendPath: '/flowlib',  // where <Flowlib> is mounted in the frontend router
  theme: 'light',           // 'light' | 'dark' | 'system'
  logging: { ... },
  execution: { ... },
  triggers: { ... },
  plugins: [ ... ],
  defaultCredentials: [ ... ],
});

export default flowlibConfig;

database (required)

FieldTypeDefaultDescription
connectionStringstringDatabase URL. SQLite: file:./dev.db. PostgreSQL: postgresql://user:pass@host:port/db. MySQL: mysql://user:pass@host:port/db. Required for every driver except d1.
type'sqlite' | 'postgresql' | 'mysql'Database dialect.
namestringOptional human-readable name.
driversee belowauto-detectedDatabase driver.
bindingD1DatabaseCloudflare D1 binding. Required (instead of connectionString) when driver is d1. Pass the env.DB your Worker received.

Supported drivers

DatabaseDriversDefault
PostgreSQLpostgres, pg, neon-serverlesspostgres
SQLitebetter-sqlite3, libsql, d1better-sqlite3
MySQLmysql2mysql2

d1 is a SQLite-dialect driver for Cloudflare Workers — pass a runtime binding instead of a connectionString:

database: {
  type: 'sqlite',
  driver: 'd1',
  binding: env.DB, // the D1Database from your Worker's env
},

logging (optional)

FieldTypeDefaultDescription
level'debug' | 'info' | 'warn' | 'error' | 'silent''silent'Global log level.
scopesRecord<string, LogLevel>Per-scope overrides.

Available scopes: execution, validation, batch, database, node, graph, credentials, ai, template, renderer, flows, versions, http

logging: {
  level: 'info',
  scopes: {
    execution: 'debug',
    batch: 'silent',
    ai: 'debug',
  },
}

execution (optional)

FieldTypeDefaultDescription
defaultTimeoutnumber60000Node execution timeout (ms).
maxConcurrentExecutionsnumber10Maximum parallel flow runs.
enableTracingbooleantrueStore node-level execution traces.
flowTimeoutMsnumber600000Stale-run heartbeat threshold (10 min). A run is failed only if heartbeats stop, not on wall-clock.
modelNodeTimeoutMsnumber300000Per-node timeout for core.model (5 min) unless the node sets its own timeoutMs.
agentNodeTimeoutMsnumber900000Per-node timeout for the core.agent loop (15 min) unless the node sets its own timeoutMs.
heartbeatIntervalMsnumber30000Heartbeat write interval during a run (ms).
staleRunCheckIntervalMsnumber60000Stale-run detector poll interval (ms).
sseHeartbeatIntervalMsnumber15000SSE keep-alive frame interval for the run event stream (ms). Lower it behind aggressive proxies.
disableNativeEvalbooleanfalseForce-disable the new Function fast path in DirectEvaluator (edge-runtime hosts only).
persistence'per-node' | 'per-run''per-node'Node-execution write strategy. 'per-run' buffers in memory and flushes one blob on completion (~30× fewer writes) at the cost of in-flight node visibility.

triggers (optional)

FieldTypeDefaultDescription
webhookBaseUrlstringPublic URL prefix for webhook URLs.
cronEnabledbooleantrueEnable/disable cron scheduler.

plugins (optional)

Array of plugin instances, initialised in order:

plugins: [
  auth({
    /* ... */
  }),
  rbac(),
  webhooks({ webhookBaseUrl: 'https://api.myapp.com/flowlib' }),
];

defaultCredentials (optional)

Array of credentials to seed on startup. Matched by name — existing credentials not overwritten.

FieldTypeRequiredDescription
namestringYesUnique credential name.
type'llm' | 'http-api' | 'database'YesCredential category.
providerstringFor llmProvider ID (openai, anthropic, openrouter).
authTypestringYesAuth method (apiKey, oauth2).
configRecord<string, unknown>YesProvider-specific config.
descriptionstringNoHuman-readable note.
isSharedbooleanNoVisible to all users.

apiPath (optional)

The URL path where the Flowlib API is mounted (e.g. '/api/flowlib' or 'http://localhost:3000/flowlib'). Read by <Flowlib> on the frontend to know where to send API requests.

frontendPath (optional)

The URL path where <Flowlib> is mounted in the frontend router (e.g. '/flowlib'). Used for internal navigation and the OAuth callback route (<frontendPath>/oauth/callback).

theme (optional)

'light' | 'dark' | 'system' — default 'dark'. Controls the editor color scheme. Read by <Flowlib> on the frontend.

logger (optional)

Custom logger instance. Must implement info, debug, warn, error methods.

Edge / serverless options (optional)

These matter only on cold-start-per-request runtimes (Cloudflare Workers, Vercel, etc.). Self-hosted long-running servers can ignore them.

FieldTypeDefaultDescription
skipDatabaseInitbooleanfalseThrow before connecting to the database — used by build steps. The Next.js adapter sets this automatically during a production build.
skipStartupChecksbooleanfalseSkip the per-startup connectivity probe and table/schema checks. Use only when the deploy pipeline already ran generate + push; saves ~4 DB round-trips per cold start.
servicesobjectAdapter overrides for cross-cutting infrastructure (encryption, eventBus, chatSessionStore, cronScheduler, batchPoller, jobRunner). Edge runtimes inject runtime-native implementations here.
authobjectAuthorization config for the RBAC layer (customAuthorize callback, etc.). Consumed by plugin onAuthorize hooks.

Full example

flowlib.config.ts
import { defineConfig } from '@flowlib/core';
import { auth } from '@flowlib/user-auth';
import { rbac } from '@flowlib/rbac';

export const flowlibConfig = defineConfig({
  database: {
    type: 'postgresql',
    connectionString: process.env.DATABASE_URL,
  },
  apiPath: '/api/flowlib',
  frontendPath: '/flowlib',
  theme: 'light',
  logging: {
    level: 'info',
    scopes: { execution: 'debug' },
  },
  execution: {
    defaultTimeout: 120000,
    maxConcurrentExecutions: 20,
    flowTimeoutMs: 600_000,
  },
  triggers: {
    webhookBaseUrl: process.env.WEBHOOK_BASE_URL,
    cronEnabled: true,
  },
  plugins: [
    auth({
      betterAuthOptions: { secret: process.env.BETTER_AUTH_SECRET },
      globalAdmins: [
        { email: process.env.ADMIN_EMAIL, pw: process.env.ADMIN_PASSWORD, name: 'Admin' },
      ],
    }),
    rbac(),
  ],
  defaultCredentials: [
    {
      name: 'OpenAI',
      type: 'llm',
      provider: 'openai',
      authType: 'apiKey',
      config: { apiKey: process.env.OPENAI_API_KEY },
      isShared: true,
    },
  ],
});

On this page