Check if the internet connection is up
Works in Node.js, CLI and the browser (with browserify).
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
var isOnline = require('is-online'); isOnline(err, online) { console.log(online); //=> true });
Required
Type: function
error
is there only by Node.js convention and is always null
.
Required
Type: function
$ npm install --global is-online
$ is-online --help
Example
is-online
✔︎ Online
MIT © Sindre Sorhus