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 globtsconfig
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 sentenableConsoleLogging / disableConsoleInterceptor
ts
enableConsoleLogging: true, // enable console output in dev CLI
disableConsoleInterceptor: false, // prevent logs going to dashboardmaxDuration
ts
maxDuration: 60, // seconds — global default for all tasksprocessKeepAlive
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:
| Extension | Purpose |
|---|---|
prismaExtension | Prisma ORM integration |
pythonExtension | Execute Python scripts |
puppeteer | Headless Chrome |
ffmpeg | Media processing |
aptGet | System packages |
additionalFiles | Copy extra files to build |
additionalPackages | Install extra npm packages |
syncEnvVars | Sync env vars from external services |
syncVercelEnvVars | Sync from Vercel |
syncNeonEnvVars | Sync from Neon DB |
esbuildPlugin | Custom esbuild plugins |
emitDecoratorMetadata | TypeScript decorator metadata |
audioWaveform | Audio waveform support |
See Build Extensions for full documentation.