DEV Community

Alex Spinov
Alex Spinov

Posted on

Trigger.dev v3 Has a Free API That Runs Background Jobs Without Infrastructure

Trigger.dev v3 is the open-source background job platform for TypeScript. Write async tasks as normal functions, deploy them, and let Trigger.dev handle queues, retries, and scheduling.

What Is Trigger.dev?

Trigger.dev runs your long-running tasks in the cloud. No Redis, no Bull, no worker infrastructure. Just TypeScript functions that run reliably.

Quick Start

npx trigger.dev@latest init
Enter fullscreen mode Exit fullscreen mode

Define a Task

// trigger/tasks/process-video.ts
import { task } from '@trigger.dev/sdk/v3'

export const processVideo = task({
  id: 'process-video',
  maxDuration: 300, // 5 minutes
  retry: { maxAttempts: 3 },
  run: async (payload: { videoUrl: string; userId: string }) => {
    // Download video
    const video = await downloadVideo(payload.videoUrl)

    // Transcode
    const transcoded = await transcodeToMP4(video)

    // Upload to S3
    const url = await uploadToS3(transcoded)

    // Notify user
    await sendNotification(payload.userId, `Video ready: ${url}`)

    return { url, duration: video.duration }
  },
})
Enter fullscreen mode Exit fullscreen mode

Trigger from Your App

import { tasks } from '@trigger.dev/sdk/v3'
import type { processVideo } from './trigger/tasks/process-video'

// From API route, webhook handler, etc.
const handle = await tasks.trigger<typeof processVideo>('process-video', {
  videoUrl: 'https://example.com/video.mp4',
  userId: 'user-123',
})

console.log(`Job started: ${handle.id}`)

// Poll for result (or use webhook)
const result = await tasks.poll(handle, { pollIntervalMs: 1000 })
console.log(`Video URL: ${result.url}`)
Enter fullscreen mode Exit fullscreen mode

Scheduled Tasks (Cron)

import { schedules } from '@trigger.dev/sdk/v3'

export const dailyReport = schedules.task({
  id: 'daily-report',
  cron: '0 9 * * *', // 9 AM daily
  run: async () => {
    const metrics = await fetchDailyMetrics()
    await sendSlackReport(metrics)
    return { sent: true, metrics }
  },
})
Enter fullscreen mode Exit fullscreen mode

Batch Processing

import { task, batch } from '@trigger.dev/sdk/v3'

export const processImages = task({
  id: 'process-images',
  run: async (payload: { images: string[] }) => {
    // Process all images in parallel
    const results = await batch.triggerAndWait(
      payload.images.map(url => ({
        id: 'resize-image',
        payload: { url, width: 800 },
      }))
    )
    return results
  },
})
Enter fullscreen mode Exit fullscreen mode

REST API

export TRIGGER_TOKEN="your-secret-key"

# Trigger a task
curl -s -X POST 'https://api.trigger.dev/api/v1/tasks/process-video/trigger' \
  -H "Authorization: Bearer $TRIGGER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"payload": {"videoUrl": "https://example.com/vid.mp4", "userId": "user-123"}}'

# Get run status
curl -s 'https://api.trigger.dev/api/v3/runs/RUN_ID' \
  -H "Authorization: Bearer $TRIGGER_TOKEN" | jq '{status, output}'
Enter fullscreen mode Exit fullscreen mode

Free Tier

Feature Free Hobby ($29/mo)
Runs 50K/mo 250K/mo
Concurrency 10 100
Max duration 5 min 60 min
Schedules 5 100
Log retention 1 day 7 days

Need background scraping jobs? Scrapfly + Trigger.dev = scheduled web data extraction. Email spinov001@gmail.com for custom solutions.

Top comments (0)