Popularity
6.6
-
Activity
2.9
Declining
803
23
74

Monthly Downloads: 0
Programming language: JavaScript
License: MIT License
Tags: Command Line Apps     Network     Socket     Browser     Detect     Has     Internet     Is     Accessible     Reachability     Reachable     Dns     Hostnames     Hostname     Connectivity     Connected     Is-online     Offline     Online    
Latest version: v8.2.0

is-online alternatives and similar modules

Based on the "Command Line Apps" category

Do you think we are missing an alternative of is-online or a related project?

Add another 'Command Line Apps' Module

README

is-online Build Status

Check if the internet connection is up

Works in Node.js and the browser (with a bundler).

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.

Install

$ npm install is-online

Usage

const isOnline = require('is-online');

(async () => {
    console.log(await isOnline());
    //=> true
})();

API

isOnline(options?)

options

Type: object

timeout

Type: number Default: 5000

Milliseconds to wait for a server to respond.

version

Type: string Values: 'v4' 'v6' Default: 'v4'

Internet Protocol version to use. This is an advanced option that is usually not necessary 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
  • Query myip.opendns.com on 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 true.

Proxy support

To make it work through proxies, you need to set up global-agent.

Maintainers