What if you could write background jobs in TypeScript — with retries, scheduling, and observability — and deploy them alongside your Next.js or Remix app?
Trigger.dev is an open-source platform for running long-running background jobs in serverless environments.
Why Trigger.dev
Serverless functions timeout after 10-60 seconds. Background jobs need minutes or hours. Trigger.dev bridges this gap:
- Long-running tasks — up to 5 minutes on free tier, hours on paid
- Retries with backoff — automatic retry on failure
- Cron scheduling — built-in cron syntax
- Real-time logs — see job progress in a dashboard
- TypeScript-native — define jobs as typed functions
- Self-hostable — open source, run on your own infrastructure
Quick Start
npx trigger.dev@latest init
import { task } from "@trigger.dev/sdk/v3";
export const processOrder = task({
id: "process-order",
retry: { maxAttempts: 3 },
run: async (payload: { orderId: string }) => {
// This runs for as long as it needs — not limited by serverless timeouts
const order = await db.orders.findById(payload.orderId);
await generateInvoice(order);
await sendEmail(order.customerEmail, invoice);
await updateInventory(order.items);
return { processed: true };
},
});
Trigger from your API:
// In your Next.js API route
import { processOrder } from "@/trigger/process-order";
export async function POST(req: Request) {
const { orderId } = await req.json();
await processOrder.trigger({ orderId });
return Response.json({ status: "queued" });
}
Scheduled Jobs
import { schedules } from "@trigger.dev/sdk/v3";
export const dailyReport = schedules.task({
id: "daily-report",
cron: "0 9 * * *", // Every day at 9am
run: async () => {
const metrics = await gatherMetrics();
await sendSlackReport(metrics);
},
});
Free Tier
- 30,000 task runs/month
- Up to 5-minute execution time
- Real-time dashboard
- 3 team members
Real Use Case
A SaaS app processed CSV uploads in API routes. Large files (50K+ rows) caused Vercel function timeouts. After moving to Trigger.dev, uploads trigger a background job — no timeouts, automatic retries, users get real-time progress updates via the dashboard API.
When to Use Trigger.dev
- CSV/file processing in serverless environments
- Email sequences and notifications
- Scheduled reports and data aggregation
- Any task that exceeds serverless timeout limits
Get Started
Visit trigger.dev — open source, self-hostable, generous free tier.
Need custom data pipelines or scraping solutions? Check out my Apify actors or email me at spinov001@gmail.com for custom solutions.
Top comments (0)