hatchet-dev / hatchet-typescript

Hatchet Typescript SDK for Interacting with the Hatchet Engine
10 stars 6 forks source link

feat(handler): add nextjs pages router handler #285

Closed steebchen closed 4 weeks ago

steebchen commented 1 month ago

For a webhook route /api/webhook, use as follows in pages/api/webhook.tsx:

import { hatchet, workflow, workflow2 } from '@/lib/workflow'

const secret = process.env.HATCHET_WEBHOOK_SECRET || 'secret'

const webhooks = hatchet.webhooks([workflow, workflow2])

export default webhooks.nextJSHandler({ secret })