npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sigx/lynx-network

v0.34.0

Published

Network connectivity status for sigx-lynx

Readme

@sigx/lynx-network

Network connectivity status for sigx-lynx. NWPathMonitor on iOS, ConnectivityManager on Android.

📚 Documentation

Full guides, API reference and live examples → https://sigx.dev/lynx/modules/network/overview/

Install

pnpm add @sigx/lynx-network

sigx prebuild auto-discovers and links the native module. No special permissions on either platform.

Usage

import { Network } from '@sigx/lynx-network';
const state = await Network.getState();
if (state.isConnected && state.type === 'wifi') {
    // sync large payload
}

API

| Method | Notes | | ------------------------------------- | -------------------------------------------------------------------------------------------------- | | getState(): Promise<NetworkState> | Single async snapshot — no subscription stream yet. Rejects if the native side fails. | | isAvailable(): boolean | Whether the native module is registered in the current build. |

type ConnectionType = 'wifi' | 'cellular' | 'ethernet' | 'bluetooth' | 'none' | 'unknown';
interface NetworkState {
    isConnected: boolean;
    type: ConnectionType;
    isInternetReachable: boolean | null;   // null = unknown (e.g. captive portal)
}

Errors

getState() throws a SigxError from @sigx/lynx-core when the native side reports a failure — code: 'native_error', message [@sigx/lynx-network] getState failed: <cause>, raw native payload on cause. Branch on code, never on the message. It also throws when the native module isn't linked into the build; feature-detect with isAvailable() rather than catching that.

A failure is never reported as "offline", so an isConnected: false result can be trusted by an offline banner.

import { isSigxError } from '@sigx/lynx-core';

try {
    const state = await Network.getState();
} catch (e) {
    if (isSigxError(e) && e.code === 'native_error') {
        // couldn't read connectivity — not the same as being offline
    }
}

Web

On web the state comes from the browser: isConnected / isInternetReachable from navigator.onLine, and type from navigator.connection.type where the browser exposes it (Chromium; elsewhere it reports 'unknown', or 'none' when offline). The browser path has no failure envelope, so it never throws.

Gotchas

  • A native failure throws, it does not resolve. The native { error } envelope used to be handed back as a NetworkState with every field undefined, so if (state.isConnected) quietly took the offline branch and no catch ever ran. Callers written against that degraded shape now need a catch.
  • isInternetReachable is typed boolean | null, but nothing ever returns null today — and none of the three platforms answers it honestly. iOS sets it equal to isConnected; Android reports NET_CAPABILITY_INTERNET, which means "this transport is supposed to reach the internet", not that it does; web mirrors navigator.onLine. So on captive-portal Wi-Fi — connected to an AP, no internet until you sign in — all three say true. Don't gate a request on it; make the request and handle the failure. #894 has the decided fix: NET_CAPABILITY_VALIDATED on Android (the actual captive-portal discriminator), a genuine null on iOS (NWPath has no validation signal), navigator.onLine on web. null will then mean "unknown", which is what the type has always promised.
  • No subscription API yet, and no native publisher behind one either. To react to connectivity changes live, poll getState() from a setInterval or a small effect. There is nothing to subscribe to today: Android registers no NetworkCallback at all, and iOS's NWPathMonitor only caches the latest path for the next getState() — neither ever calls sendGlobalEvent. A Network.subscribe() + useNetwork() pair, backed by a real publisher on both platforms, is tracked on #894.

License

MIT