Examples
EventSub Webhook Server
Stand up a lightweight HTTP server that verifies EventSub webhook signatures, answers challenge requests, and logs notifications.
Environment
TWITCH_EVENTSUB_SECRET, plus optional PORT and TWITCH_EVENTSUB_PATH
Get started
- Install dependencies with
bun installif you have not already. - Choose a secret for signing EventSub payloads and export it as
TWITCH_EVENTSUB_SECRET. This must match the secret you supply when creating subscriptions. - (Optional) Set
PORTandTWITCH_EVENTSUB_PATHif you want the server to listen on something other thanhttp://localhost:3000/twitch/eventsub. - Run the server with
bun run examples/EVENTSUB_WEBHOOK_SERVER.tsand expose it to the internet using a tunnel such asngrok http 3000. - Create EventSub subscriptions that target the public URL. The script prints each notification and warns when subscriptions are revoked.
What you can do
- Verify the HMAC signature of incoming EventSub webhook requests.
- Respond to Twitch's initial challenge to confirm your endpoint automatically.
- Log subscription revocations to trigger clean-up automation.
- Forward the parsed payload to your own queue, function, or microservice.
Deployment ideas
- Wrap the handler in your preferred framework (Express, Fastify, Cloudflare Workers) while reusing the same logic.
- Add persistence to capture subscription metadata and message IDs for replay protection.
- Combine with the Helix client to subscribe programmatically once the server is online.