← Back to examples

Get started

  1. Install dependencies with npm install if you have not already.
  2. Choose a secret for signing EventSub payloads and export it as TWITCH_EVENTSUB_SECRET. This must match the secret you supply when creating subscriptions.
  3. (Optional) Set PORT and TWITCH_EVENTSUB_PATH if you want the server to listen on something other than http://localhost:3000/twitch/eventsub.
  4. Run the server with npx tsx examples/EVENTSUB_WEBHOOK_SERVER.ts and expose it to the internet using a tunnel such as ngrok http 3000.
  5. 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.