Next JS
Callbacks
Callbacks are how you can get notified when a workflow is done
Overview
In your nextjs server side, where you run your endpoint, you can queue a run and pass a webhook url to it.
Full Stack Demo
See how the callback works in a NextJS app
src/app/api/run/route.tsx
Make sure you have a route that can handle the webhook. For the response body, check the docs here
src/app/api/webhook/route.tsx
Enforcing Webhook Security
To enhance the security of your webhook endpoint, you can implement a secret token verification using the jose
library, which is compatible with edge environments. This method uses a shared secret to generate and verify signatures for each webhook request.
Here’s how to modify your code to include this security measure:
src/app/api/run/route.tsx
Then, update your webhook handler to verify the signature:
src/app/api/webhook/route.tsx
Was this page helpful?