How It Works
Trigger.dev lets you integrate long-running async tasks into your application and run them in the background — no timeouts, elastic scaling, zero infrastructure management.
Example: Video Processing Task
// /trigger/video.ts
import { logger, task } from "@trigger.dev/sdk";
import ffmpeg from "fluent-ffmpeg";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
export const convertVideo = task({
id: "convert-video",
retry: { maxAttempts: 5, minTimeoutInMs: 1000, maxTimeoutInMs: 10000, factor: 2 },
run: async ({ videoId }: { videoId: string }) => {
// ... process video with ffmpeg, upload to S3, send email
return { success: true, s3Url };
},
});Trigger it from your API route:
import { tasks } from "@trigger.dev/sdk";
import type { convertVideo } from "./trigger/video";
export async function POST(request: Request) {
const body = await request.json();
const handle = await tasks.trigger<typeof convertVideo>("convert-video", body);
return Response.json(handle);
}The CLI
npx trigger.dev@latest login # Authenticate
npx trigger.dev@latest init # Initialize in your project
npx trigger.dev@latest dev # Run tasks locally
npx trigger.dev@latest deploy # Deploy to Trigger.devSupports multiple profiles for switching between accounts or self-hosted instances.
Architecture
Trigger.dev uses a serverless architecture (without timeouts). When you deploy, task code is built and uploaded to your instance. When triggered, tasks run in secure isolated environments.
The Checkpoint-Resume System
Enables efficient long-running tasks in a serverless environment:
- Task Execution — runs in isolated environment with all resources
- Subtask Handling — trigger subtasks with
triggerAndWait() - State Checkpointing — uses CRIU to checkpoint state while waiting
- Resource Release — parent task resources released during wait
- Efficient Storage — checkpoint compressed and stored on disk
- Event-Driven Resumption — subtask completion triggers restoration
- Seamless Continuation — task resumes exactly where it left off
export const parentTask = task({
id: "parent-task",
run: async () => {
const result = await childTask.triggerAndWait({ data: "some data" });
await wait.for({ seconds: 30 }); // checkpointed, no resource consumption
return "Parent task completed";
},
});No charge for wait time
In Trigger.dev Cloud, you're not charged for time spent waiting for subtasks or in a paused state.
Durable Execution
- Complex workflows broken into smaller independent subtasks
- Each subtask assigned a unique idempotency key
- Results cached by idempotency key
- On failure: only failed subtask and subsequent tasks are retried
Build System
Powered by esbuild:
- Bundled by default — code + dependencies bundled and tree-shaked
- Build extensions — customize the build process or container image
- ESM output — enables tree-shaking and better performance
Dev Mode
npx trigger.dev@latest dev:
- Same build system as production
- Auto-detects changes and re-registers tasks
- Supports debuggers and breakpoints
- Each task runs in a separate process
- Auto-cancels tasks when dev server stops
OpenTelemetry
Dashboard powered by OpenTelemetry traces and logs. Auto-instrument with:
// trigger.config.ts
import { PrismaInstrumentation } from "@prisma/instrumentation";
import { AwsInstrumentation } from "@opentelemetry/instrumentation-aws-sdk";
export default defineConfig({
project: "<project-ref>",
instrumentations: [new PrismaInstrumentation(), new AwsInstrumentation()],
});