Skip to main content
The trigger.config.ts file is used to configure your Trigger.dev project. It is a TypeScript file at the root of your project that exports a default configuration object. Here’s an example:
trigger.config.ts
The config file handles a lot of things, like:
  • Specifying where your trigger tasks are located using the dirs option.
  • Setting the default retry settings.
  • Configuring OpenTelemetry instrumentations.
  • Customizing the build process.
  • Adding global task lifecycle functions.
The config file is bundled with your project, so code imported in the config file is also bundled, which can have an effect on build times and cold start duration. One important qualification is anything defined in the build config is automatically stripped out of the config file, and imports used inside build config with be tree-shaken out.

Dirs

You can specify the directories where your tasks are located using the dirs option:
trigger.config.ts
If you omit the dirs option, we will automatically detect directories that are named trigger in your project, but we recommend specifying the directories explicitly. The dirs option is an array of strings, so you can specify multiple directories if you have tasks in multiple locations. We will search for TypeScript and JavaScript files in the specified directories and include them in the build process. We automatically exclude files that have .test or .spec in the name, but you can customize this by specifying glob patterns in the ignorePatterns option:
trigger.config.ts

Custom tsconfig path

You can specify a custom path to your tsconfig file. This is useful if you have a custom tsconfig file that you want to use.
trigger.config.ts

Lifecycle functions

You can add lifecycle functions to get notified when any task starts, succeeds, or fails using onStart, onSuccess and onFailure:
trigger.config.ts
Read more about task lifecycle functions in the tasks overview.

Instrumentations

We use OpenTelemetry (OTEL) for our run logs. This means you get a lot of information about your tasks with no effort. But you probably want to add more information to your logs. For example, here’s all the Prisma calls automatically logged: The run log Here we add Prisma and OpenAI instrumentations to your trigger.config.ts file.
trigger.config.ts
There is a huge library of instrumentations you can easily add to your project like this. Some ones we recommend:
@opentelemetry/instrumentation-fs which logs all file system calls is currently not supported.

Telemetry Exporters

You can also configure custom telemetry exporters to send your traces, logs, and metrics to other external services. For example, you can send your logs to Axiom. First, add the opentelemetry exporter packages to your package.json file:
package.json
Axiom’s /v1/metrics endpoint only supports protobuf (application/x-protobuf), not JSON. Use @opentelemetry/exporter-metrics-otlp-proto instead of @opentelemetry/exporter-metrics-otlp-http for metrics. Traces and logs work fine with the -http (JSON) exporters.
Then, configure the exporters in your trigger.config.ts file:
trigger.config.ts
Make sure to set the AXIOM_API_TOKEN, AXIOM_DATASET, and AXIOM_METRICS_DATASET environment variables in your project. Axiom requires a separate, dedicated dataset for metrics — you cannot reuse the same dataset for traces/logs and metrics. It’s important to note that you cannot configure exporters using OTEL_* environment variables, as they would conflict with our internal telemetry. Instead you should configure the exporters via passing in arguments to the OTLPTraceExporter, OTLPLogExporter, and OTLPMetricExporter constructors. For example, here is how you can configure exporting to Honeycomb:
trigger.config.ts

Runtime

We currently only officially support the node runtime, but you can try our experimental bun runtime by setting the runtime option in your config file:
trigger.config.ts
See our Bun guide for more information.

Node.js versions

Trigger.dev runs your tasks on specific Node.js versions:

v3

  • Node.js 21.7.3

v4

  • Node.js 21.7.3 (default)
  • Node.js 22.16.0 (node-22)
  • Bun 1.3.3 (bun)
You can change the runtime by setting the runtime field in your trigger.config.ts file.

Default machine

You can specify the default machine for all tasks in your project:
trigger.config.ts
See our machines documentation for more information.

Log level

You can set the log level for your project:
trigger.config.ts
The logLevel only determines which logs are sent to the Trigger.dev instance when using the logger API. All console based logs are always sent.

Console logging

You can control console logging behavior in development:
trigger.config.ts

Max duration

You can set the default maxDuration for all tasks in your project:
trigger.config.ts
See our maxDuration guide for more information.

TTL

You can set a default time-to-live (TTL) for all task runs in your project. If a run is not dequeued within this time, it will expire and never execute.
trigger.config.ts
You can override this on a per-task basis by setting ttl on the task definition, or per-trigger by passing ttl in the trigger options. To opt a specific task out of the config-level TTL, set ttl: 0 on the task. See Time-to-live (TTL) for more information.

Process keep alive

Keep the process alive after the task has finished running so the next task doesn’t have to wait for the process to start up again. Note that the process could be killed at any time, and we don’t make any guarantees about the process being alive for a certain amount of time
trigger.config.ts
You can pass an object to the processKeepAlive option to configure the behavior:
trigger.config.ts

Development behavior

You can control the working directory behavior in development:
trigger.config.ts
When set to false, the current working directory will be set to the build directory, which more closely matches production behavior.

CA certificates

CA Cert file to be added to NODE_EXTRA_CA_CERT environment variable, useful in use with self signed cert in the trigger.dev environment.
trigger.config.ts

Build configuration

You can customize the build process using the build option:
trigger.config.ts
The trigger.config.ts file is included in the bundle, but with the build configuration stripped out. These means any imports only used inside the build configuration are also removed from the final bundle.

External

All code is bundled by default, but you can exclude some packages from the bundle using the external option:
trigger.config.ts
When a package is excluded from the bundle, it will be added to a dynamically generated package.json file in the build directory. The version of the package will be the same as the version found in your node_modules directory. Each entry in the external should be a package name, not necessarily the import path. For example, if you want to exclude the ai package, but you are importing ai/rsc, you should just include ai in the external array:
trigger.config.ts

WebAssembly (WASM) packages

Packages that use WebAssembly (WASM) must be added to the external array. WASM files are binary modules that need to be loaded at runtime and cannot be bundled into JavaScript code. When you add a WASM package to external, the package will be installed as a dependency in the runtime environment, ensuring the WASM files are available at their expected paths.
trigger.config.ts
Any packages that install or build a native binary or use WebAssembly (WASM) should be added to external, as they cannot be bundled. For example, re2, sharp, sqlite3, and WASM packages should be added to external.

JSX

You can customize the jsx options that are passed to esbuild using the jsx option:
trigger.config.ts
By default we enabled esbuild’s automatic JSX runtime which means you don’t need to import React in your JSX files. You can disable this by setting automatic to false. See the esbuild JSX documentation for more information.

Conditions

You can add custom import conditions to your build using the conditions option:
trigger.config.ts
These conditions effect how imports are resolved during the build process. For example, the react-server condition will resolve ai/rsc to the server version of the ai/rsc export. Custom conditions will also be passed to the node runtime when running your tasks.

Extensions

Build extension allow you to hook into the build system and customize the build process or the resulting bundle and container image (in the case of deploying). You can use pre-built extensions by installing the @trigger.dev/build package into your devDependencies, or you can create your own.

additionalFiles

See the additionalFiles documentation for more information.

additionalPackages

See the additionalPackages documentation for more information.

emitDecoratorMetadata

See the emitDecoratorMetadata documentation for more information.

Prisma

See the prismaExtension documentation for more information.

syncEnvVars

See the syncEnvVars documentation for more information.

puppeteer

See the puppeteer documentation for more information.

ffmpeg

See the ffmpeg documentation for more information.

esbuild plugins

See the esbuild plugins documentation for more information.

aptGet

See the aptGet documentation for more information.