docs/migration-mergent.mdx
Mergent is being absorbed into Resend, so if you’re running background jobs or scheduled tasks on Mergent, now is a good time to migrate. Trigger.dev is a modern, developer-friendly platform for background jobs, workflows, and scheduling.
trigger.config.ts file.npx trigger.dev@latest init
npx trigger.dev@latest dev
You’ll get a local server that behaves just like production, and you’ll see your runs in the dashboard.
Here’s a simple Mergent task that processes an image:
export async function processVideoTask(req: { body: { videoUrl: string } }) {
const { videoUrl } = req.body;
// Do some video processing
const result = await processVideo(videoUrl);
return { success: true, processedUrl: result.url };
}
This is typically called by Mergent via HTTP POST, and you’d register the endpoint in the Mergent dashboard.
import { task } from "@trigger.dev/sdk";
export const processVideoTask = task({
id: "process-video",
run: async (payload: { videoUrl: string }) => {
const result = await processVideo(payload.videoUrl);
return { success: true, processedUrl: result.url };
},
});
Key differences:
task() function that gets deployed on a managed worker for you.Mergent scheduled task:
You’d set up a schedule in the Mergent dashboard to hit your HTTP endpoint on a cron.
export async function dailyReportTask(req) {
await sendDailyReport();
}
Trigger.dev scheduled task:
import { schedules } from "@trigger.dev/sdk";
export const dailyReportTask = schedules.task({
id: "daily-report",
cron: "0 0 * * *", // every day at midnight UTC
run: async () => {
await sendDailyReport();
},
});
Mergent: You’d trigger a task by calling the Mergent API, specifying the URL and payload.
const Mergent = require("mergent");
const mergent = new Mergent("API_KEY");
mergent.tasks.create({
request: {
url: "https://your-app.com/api/processImage",
body: JSON.stringify({ imageUrl: "...", filters: ["blur"] }),
headers: { "Content-Type": "application/json" },
},
delay: { minutes: 5 },
});
Trigger.dev: You trigger a task directly from your codebase, no HTTP endpoint needed.
import { processImageTask } from "@/trigger/processImage";
await processImageTask.trigger({
imageUrl: "...",
filters: ["blur"],
}, {
delay: "5m",
});
wait.for or wait.until).Summary:
That’s it. You’re ready to migrate. If you need more advanced features such as concurrency, retries, metadata, chaining tasks, and more, check out the Trigger.dev docs.