Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is true and in general websockets (well, and webtransport/webrtc etc) are the only reliable way to detect navigation from the backend since none of the methods mentioned in the article work if the user simply closed the tab.



onunload/onbeforeunload doesn't work?


Not always, not necessarily if the tab was in the background when closed (switch then close), not if they force quit (like the other comment I upvoted says), not if chrome updates etc. The other alternatives are opening another type of connection like an RTCPeerConnection to your server and seeing when that closes.


What if they kill -9 the browser process?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: