Skip to content

trigger.config.ts Reference

The main configuration file for your Trigger.dev project. A TypeScript file at the project root that exports a default config object.

Basic Example

ts
import { defineConfig } from "@trigger.dev/sdk";

export default defineConfig({
  project: "<project ref>",
  dirs: ["./trigger"],
  retries: {
    enabledInDev: false,
    default: {
      maxAttempts: 3,
      minTimeoutInMs: 1000,
      maxTimeoutInMs: 10000,
      factor: 2,
      randomize: true,
    },
  },
});

Key Options

dirs

Directories where tasks are located. Auto-detects trigger named dirs if omitted.

ts
dirs: ["./trigger"],
ignorePatterns: ["**/*.my-test.ts"], // exclude via glob

tsconfig

ts
tsconfig: "./custom-tsconfig.json",

Lifecycle Functions

Global hooks applied to all tasks:

ts
onSuccess: async ({ payload, output, ctx }) => { /* ... */ },
onFailure: async ({ payload, error, ctx }) => { /* ... */ },
onStart: async ({ payload, ctx }) => { /* ... */ },
init: async ({ payload, ctx }) => { /* runs before any task */ },

Instrumentations (OpenTelemetry)

ts
telemetry: {
  instrumentations: [
    new PrismaInstrumentation(),
    new OpenAIInstrumentation(),
  ],
}

Common instrumentation packages:

  • @opentelemetry/instrumentation-http — HTTP calls
  • @prisma/instrumentation — Prisma
  • @traceloop/instrumentation-openai — OpenAI

Telemetry Exporters

Send traces to Axiom, Honeycomb, etc.:

ts
telemetry: {
  logExporters: [new OTLPLogExporter({ url: "...", headers: {...} })],
  exporters: [new OTLPTraceExporter({ url: "...", headers: {...} })],
  metricExporters: [new OTLPMetricExporter({ url: "...", headers: {...} })],
}

WARNING

Cannot use OTEL_* env vars — configure exporters directly in config.

runtime

ts
runtime: "node",     // default (Node.js 21.7.3)
runtime: "node-22",  // Node.js 22.16.0 (v4 only)
runtime: "bun",      // Bun 1.3.3 (v4 only, experimental)

defaultMachine

ts
defaultMachine: "large-1x",

logLevel

ts
logLevel: "debug", // affects logger API only; console.log always sent

enableConsoleLogging / disableConsoleInterceptor

ts
enableConsoleLogging: true,       // enable console output in dev CLI
disableConsoleInterceptor: false, // prevent logs going to dashboard

maxDuration

ts
maxDuration: 60, // seconds — global default for all tasks

processKeepAlive

ts
processKeepAlive: {
  enabled: true,
  maxExecutionsPerProcess: 50, // kill process after N runs
  devMaxPoolSize: 25,          // max concurrent processes in dev
},

legacyDevProcessCwdBehaviour

ts
legacyDevProcessCwdBehaviour: false, // false = CWD matches production (build dir)

extraCACerts

ts
extraCACerts: "./certs/ca.crt", // must start with "./"

Build Configuration

ts
build: {
  external: ["header-generator"], // exclude from bundle
  autoDetectExternal: true,
  keepNames: true,
  minify: false, // experimental
  jsx: {
    fragment: "Fragment",
    factory: "h",
    automatic: false,
  },
  conditions: ["react-server"],
  extensions: [...],
},

External rules:

  • Use package name, not import path ("ai" not "ai/rsc")
  • Required for WASM packages and native binaries (re2, sharp, sqlite3)
  • Build config is stripped from bundle

Build Extensions

Available via @trigger.dev/build:

ExtensionPurpose
prismaExtensionPrisma ORM integration
pythonExtensionExecute Python scripts
puppeteerHeadless Chrome
ffmpegMedia processing
aptGetSystem packages
additionalFilesCopy extra files to build
additionalPackagesInstall extra npm packages
syncEnvVarsSync env vars from external services
syncVercelEnvVarsSync from Vercel
syncNeonEnvVarsSync from Neon DB
esbuildPluginCustom esbuild plugins
emitDecoratorMetadataTypeScript decorator metadata
audioWaveformAudio waveform support

See Build Extensions for full documentation.

Built from official Trigger.dev documentation