Check if the internet connection is up
Works in Node.js and the browser (with browserify/webpack).
In the browser you have
navigator.onLine, but it's useless as it only tells you if there's a local connection, and not whether the internet is accessible.
$ npm install --save is-online
const isOnline = ;;
Milliseconds to wait for a server to respond.
Internet Protocol version to use. This is an advanced option that is usually not neccessary to be set, but it can prove useful to specifically assert IPv6 connectivity.
How it works
The following checks are run in parallel:
- Retrieve icanhazip.com via HTTPS
myip.opendns.comon OpenDNS (Node.js only)
- Retrieve Apple's Captive Portal test page (Node.js only)
When the first check succeeds, the returned Promise is resolved to
MIT © Sindre Sorhus