Overview
Trigger.dev is a background task platform built for long-running async work. Your task code runs in isolated, managed environments with no timeout limits. Trigger.dev handles scheduling, queuing, retries, and observability so you can focus on the logic inside your tasks. A typical flow looks like this:- You write a task as an exported async function in your codebase
- In development, the CLI runs tasks locally in your Node.js process
- In production, the CLI builds and deploys your tasks as a Docker image
- When your application triggers a task, Trigger.dev queues and executes it
- Results, logs, and traces are visible in real time in the dashboard
The CLI
All interaction with Trigger.dev starts with the CLI, installed vianpx trigger.dev@latest.
Dev mode
Runningnpx trigger.dev@latest dev starts a local worker that connects to Trigger.dev Cloud (or your self-hosted instance). Task scheduling and queuing happen on the Trigger.dev server, but task code executes locally in your Node.js process.
Dev mode behavior:
- Hot reload — Changes to files in your
/triggerdirectory are detected automatically and a new worker version is registered - Local execution — Each task runs in a separate local process, so you can attach a debugger, add breakpoints, and inspect state
- Same build system — Code is built with esbuild the same way as production, so dev and prod behavior is consistent
- Auto-cancel — Running tasks are cancelled when you stop the dev server
Trigger.dev does not support offline dev mode. An internet connection is required to connect to the Trigger.dev server for scheduling.
Deployment
Runningnpx trigger.dev@latest deploy builds your task code and publishes it to Trigger.dev.
The build system
The build system is powered by esbuild:- Bundled by default — Your code and its dependencies are bundled and tree-shaken into a single output
- ESM output — Output targets ESM for better tree-shaking and compatibility
- Build extensions — Customize the build or the resulting Docker image using extensions (Prisma, Python, Playwright, FFmpeg, etc.)
--dry-run flag:
trigger.config.ts:
Environments
Trigger.dev supportsdev, staging, and prod environments. Each environment has its own API key. Deploy to a specific environment with the --env flag:
The run lifecycle
When you trigger a task, Trigger.dev creates a run and processes it through the following stages: Each run goes through these states:- Queued — The run is waiting to be picked up by a worker
- Executing — A worker is actively running the task
- Waiting — The task is paused (waiting for a subtask, duration, or token)
- Completed — The task finished successfully and returned output
- Failed — The task threw an error; a retry may be scheduled based on the task’s retry config
- Cancelled — The run was cancelled before or during execution
runs.retrieve:
The Checkpoint-Resume System
Trigger.dev implements a Checkpoint-Resume System that lets tasks pause execution without holding compute resources. This enables:- Waiting for subtasks — A parent task can call
childTask.triggerAndWait()and pause until the child completes - Timed delays —
wait.for({ seconds: 30 })suspends the task for any duration - Human-in-the-loop —
wait.forToken()pauses until an external agent completes a token - No idle compute cost — Paused tasks don’t consume resources, and on Trigger.dev Cloud you’re not charged for wait time
Example: parent and child tasks
On Trigger.dev Cloud, you are not charged for time spent waiting in a checkpointed state — only for active compute time.
Durable execution with idempotency keys
For complex workflows that coordinate multiple subtasks, Trigger.dev supports idempotency keys to prevent duplicate work on retries. When a subtask completes, its output is cached against the idempotency key. If the parent task retries and calls the same subtask again, the cached result is returned immediately.sendConfirmationEmail fails and the workflow retries, chargeCustomer and fulfillOrder return their cached results. Only the failed step is re-executed.
Observability with OpenTelemetry
Every task run is traced using OpenTelemetry. Trigger.dev automatically captures spans for your task execution, subtask calls, and wait points. Logs emitted withlogger are correlated to the current trace.
trigger.config.ts to trace your database queries, HTTP calls, and third-party SDK calls:
Next steps
Quickstart
Follow the step-by-step guide to run your first task.
Writing tasks
Explore all the options for defining tasks — queues, middleware, hooks, and more.
Wait & suspend
Learn all the ways tasks can pause — durations, events, subtasks, and tokens.
Configuration
Configure the build system, extensions, and runtime settings.