A Node.js and browser library to reliably check internet connectivity, going beyond navigator.onLine.
is-online is a JavaScript library that checks if an internet connection is truly active and accessible. It solves the problem of `navigator.onLine` being unreliable in browsers by performing actual network requests to external services. The library works in both Node.js and browser environments, providing a promise-based API with configurable options like timeout, protocol version, and fallback URLs.
Node.js developers and frontend engineers who need to programmatically verify internet availability for features like offline mode detection, sync operations, or conditional UI rendering.
Developers choose is-online because it offers a robust, cross-platform solution that goes beyond basic online/offline detection. Its parallel checks, diagnostic capabilities, and customization options make it more reliable than ad-hoc implementations or the limited browser API.
Check if the internet connection is up
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Performs parallel checks against multiple well-known services like icanhazip.com and Cloudflare, ensuring it detects true internet access rather than just local connectivity, as detailed in the 'How it works' section.
Works in both Node.js and modern browsers when bundled, providing a unified API for different platforms, as stated in the README's requirements and usage examples.
Offers options like custom timeouts, abort signals, IPv4/IPv6 selection, and fallback URLs, allowing tailored connectivity testing, as shown in the API documentation.
In Node.js, publishes failure details via the Diagnostics Channel, helping developers troubleshoot network issues, as explained in the Diagnostics section.
Relies on third-party URLs for checks; if these are blocked or down, it can cause false negatives unless custom fallback URLs are configured, as noted in the fallbackUrls option.
Cannot be used directly in browsers without a bundler like Webpack or Vite, adding overhead for simple client-side scripts, as specified in the requirements.
Only provides a one-off check; developers must implement polling or event listeners for real-time connectivity changes, which increases code complexity.
Requires Node.js 20 or higher, excluding older environments that might still be in use, as mentioned in the requirements.