Skip to content

Commit 3d744c6

Browse files
authored
Mergent migration guide (#1988)
* Adds a migration guide for converting mergent tasks to trigger.dev * Adds link to migration guide in the docs side bar
1 parent 5691480 commit 3d744c6

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

docs/docs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@
355355
"guides/examples/vercel-sync-env-vars"
356356
]
357357
},
358+
{
359+
"group": "Migration guides",
360+
"pages": ["migration-mergent"]
361+
},
358362
{
359363
"group": "Community packages",
360364
"pages": [

docs/migration-mergent.mdx

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: "Migrating from Mergent"
3+
description: "A guide for migrating from Mergent to Trigger.dev"
4+
sidebarTitle: "Migrating from Mergent"
5+
---
6+
7+
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.
8+
9+
### Why Trigger.dev?
10+
11+
- **Long-running, reliable tasks:** Write typical async code, no unfamiliar syntax to learn.
12+
- **Automatic retries, concurrency, and scheduling:** Configure your tasks in your `trigger.config.ts` file.
13+
- **Local dev that matches prod:** Run and debug jobs locally and view everything in the dashboard.
14+
- **Scales with you:** Deploy your tasks to Trigger.dev Cloud with no infrastructure to manage. Or self-host.
15+
16+
## How to migrate to Trigger.dev
17+
18+
### Step 1: Set up Trigger.dev
19+
20+
1. **Create an account** at [Trigger.dev Cloud](https://cloud.trigger.dev).
21+
2. **Create an organization and a project.**
22+
3. **Install the CLI** and run the local dev server:
23+
24+
```bash
25+
npx trigger.dev@latest init
26+
npx trigger.dev@latest dev
27+
```
28+
29+
You’ll get a local server that behaves just like production, and you’ll see your runs in the dashboard.
30+
31+
### Step 2: Convert your Mergent task to a Trigger.dev task
32+
33+
#### Example: Basic Mergent Task
34+
35+
Here’s a simple Mergent task that processes an image:
36+
37+
```ts processVideo.ts
38+
export async function processVideoTask(req: { body: { videoUrl: string } }) {
39+
const { videoUrl } = req.body;
40+
// Do some video processing
41+
const result = await processVideo(videoUrl);
42+
return { success: true, processedUrl: result.url };
43+
}
44+
```
45+
46+
This is typically called by Mergent via HTTP POST, and you’d register the endpoint in the Mergent dashboard.
47+
48+
#### The same task in Trigger.dev
49+
50+
```ts trigger/processVideo.ts
51+
import { task } from "@trigger.dev/sdk/v3";
52+
53+
export const processVideoTask = task({
54+
id: "process-video",
55+
run: async (payload: { videoUrl: string }) => {
56+
const result = await processVideo(payload.videoUrl);
57+
return { success: true, processedUrl: result.url };
58+
},
59+
});
60+
```
61+
62+
**Key differences:**
63+
64+
- In Mergent, your task is an HTTP handler; in Trigger.dev, it’s a `task()` function that gets deployed on a managed worker for you.
65+
- Trigger.dev gives you a typed payload, not a raw HTTP request.
66+
- No need to handle HTTP status codes or errors—Trigger.dev handles retries and failures for you.
67+
- You can export multiple tasks from a single file.
68+
69+
---
70+
71+
#### Scheduled task example
72+
73+
**Mergent scheduled task:**
74+
75+
You’d set up a schedule in the Mergent dashboard to hit your HTTP endpoint on a cron.
76+
77+
```ts dailyReport.ts
78+
export async function dailyReportTask(req) {
79+
await sendDailyReport();
80+
}
81+
```
82+
83+
**Trigger.dev scheduled task:**
84+
85+
```ts trigger/dailyReport.ts
86+
import { schedules } from "@trigger.dev/sdk/v3";
87+
88+
export const dailyReportTask = schedules.task({
89+
id: "daily-report",
90+
cron: "0 0 * * *", // every day at midnight UTC
91+
run: async () => {
92+
await sendDailyReport();
93+
},
94+
});
95+
```
96+
97+
- In Trigger.dev, you can define the schedule right in your code (or attach it in the dashboard).
98+
- No need to set up HTTP endpoints for each scheduled job.
99+
100+
## Triggering your tasks
101+
102+
**Mergent:** You’d trigger a task by calling the Mergent API, specifying the URL and payload.
103+
104+
```ts
105+
const Mergent = require("mergent");
106+
const mergent = new Mergent("API_KEY");
107+
108+
mergent.tasks.create({
109+
request: {
110+
url: "https://your-app.com/api/processImage",
111+
body: JSON.stringify({ imageUrl: "...", filters: ["blur"] }),
112+
headers: { "Content-Type": "application/json" },
113+
},
114+
delay: { minutes: 5 },
115+
});
116+
```
117+
118+
**Trigger.dev:** You trigger a task directly from your codebase, no HTTP endpoint needed.
119+
120+
```ts
121+
import { processImageTask } from "@/trigger/processImage";
122+
123+
await processImageTask.trigger({
124+
imageUrl: "...",
125+
filters: ["blur"],
126+
}, {
127+
delay: "5m",
128+
});
129+
```
130+
131+
- You can trigger tasks immediately, or add logic inside the task to delay execution (using `wait.for` or `wait.until`).
132+
- No need to expose HTTP endpoints for every task.
133+
134+
**Summary:**
135+
- Mergent tasks are HTTP handlers; Trigger.dev tasks are functions that get deployed on a managed worker for you.
136+
- Scheduling and retries are built-in and configured in code.
137+
- Trigger.dev tasks are type-safe, and easy to debug.
138+
- You don’t need to manage endpoints or handle HTTP manually.
139+
140+
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](https://trigger.dev/docs).

0 commit comments

Comments
 (0)