← Back to examples

Get started

  1. Install dependencies with npm install if you have not already.
  2. Run npx tsx examples/EVENTSUB_WEBSOCKET_MONITOR.ts to connect to the EventSub gateway.
  3. Watch the console for the printed session ID. Supply that value when creating WebSocket subscriptions through the Helix API or Twitch CLI.
  4. Trigger events (such as going live or redeeming channel points) to see the payload logged to the console.

What you can do

  • Observe EventSub session lifecycle events including reconnect requests and close codes.
  • Monitor keepalive frequency to validate that your connection stays healthy.
  • Log and inspect JSON payloads for subscriptions before wiring them into your production pipeline.
  • Reuse the connected client inside your own application to fan out notifications.

Next steps

  • Persist the session ID and reuse it across deployments to avoid creating duplicate subscriptions.
  • Add reconnection metrics or alerting by reacting to the reconnect and close events.
  • Pair this listener with the Helix client to programmatically register subscriptions when the socket connects.