You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/frameworks/nextjs-webhooks.mdx
+15-18Lines changed: 15 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,9 @@ description: "Learn how to trigger a task from a webhook in a Next.js app."
9
9
-[A Next.js project, set up with Trigger.dev](/guides/frameworks/nextjs)
10
10
-[cURL](https://curl.se/) installed on your local machine. This will be used to send a POST request to your webhook handler.
11
11
12
-
## Adding a webhook handler
12
+
## Adding the webhook handler
13
13
14
-
The webhook handler will be an API route. The location of the route file will be different depending on whether you are using the pages router or the app router.
14
+
The webhook handler in this guide will be an API route. The location of the route file will be different depending on whether you are using the Next.js pages router or the app router.
15
15
16
16
-**Pages router** - create a new file `pages/api/webhook-handler.ts` or `pages/api/webhook-hander.js`.
17
17
@@ -27,22 +27,19 @@ import { tasks } from "@trigger.dev/sdk/v3";
27
27
import { NextResponse } from"next/server";
28
28
29
29
exportasyncfunction POST(req:Request) {
30
-
try {
31
-
// Parse the webhook payload
32
-
const webhookData =awaitreq.json();
33
-
34
-
// Trigger the helloWorldTask with the webhook data as the payload
This will send a POST request to your webhook handler, with a JSON payload.
95
+
96
+
</Step>
97
+
98
+
<Steptitle="Check the task ran successfully">
99
+
100
+
After running the command, you should see a successful dev run and a 200 response in your terminals.
101
+
102
+
If you now go to your [Trigger.dev dashboard](https://cloud.trigger.dev), you should also see a successful run for the 'Hello World' task, with the payload you sent, in this case; `{"name": "John Doe", "age": "87"}`.
Copy file name to clipboardExpand all lines: docs/guides/frameworks/webhooks-guides-overview.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ description: "Guides for using webhooks with Trigger.dev."
8
8
9
9
Webhooks are a way to send and receive events from external services. Triggering tasks using webhooks allow you to add real-time, event driven functionality to your app.
10
10
11
-
A webhook handler is code that executes in response to an event. They can be endpoints in your framework's routing which will be triggered by an external service.
11
+
A webhook handler is code that executes in response to an event. They can be endpoints in your framework's routing which can be triggered by an external service.
0 commit comments