Works in Node.js and the browser (with a bundler). In the browser, there is already navigator.onLine, but it's useless as it only tells you if there's a local connection, and not whether the internet ...