Open a Websocket connection to
wss://qa.sockets.stackexchange.com/, then send the message
TAG is the tag you want to watch for. When a new question is posted, you’ll be sent a message with the question ID.
The question data needs to be retrieved separately (as of SE’s winter 2021/2022 redesign). One way to do it – as SE does it on
/newest pages – is to POST to
/posts/ajax-load-realtime-list/ with the question ID, and it will respond with the question summary. (Unfortunately, due to cross-origin restrictions, this approach can’t be embedded into a live Stack Snippet)
Open a blank page on Stack Overflow, such as this one, and then paste the following into your console, and you’ll see new questions appear on the page as they’re posted:
If you want to use this anywhere else other than on a Stack Exchange site, you might also wish to embed their CSS
You do need to listen for a
hb message and reply to it, so that StackExchange knows to keep the connection alive.