How to get and listen realtime channel events in JavaScript

Connect to pubsub.

PubSub is a websocket protocol, so you can just raise a client side socket connection.

Here is a node equivalent, all of the code can be copied over and used in a browser, just remove the node bits, WS is built into browsers https://github.com/BarryCarlyon/twitch_misc/tree/main/pubsub

TwitchDev itself has a “client side” example here GitHub - twitchdev/pubsub-javascript-sample