Next.js Webhooks
Protect your Next.js API routes with Relay and verify webhooks.
Verifying Webhooks
When Relay forwards a request to your API, it includes an x-relay-signature header. You can verify this signature in your Next.js App Router Route Handlers (e.g., app/api/webhook/route.ts) using Node.js's built-in crypto.verify method.
Below is a complete example of a Next.js App Router webhook endpoint that securely validates inbound requests from Relay.
- A Next.js project using the App Router.
- Your Relay Webhook Secret stored in
process.env.RELAY_WEBHOOK_SECRET.