Lynx/Modules/Network/API reference
@sigx/lynx-network · Stable

API reference#

Exports of @sigx/lynx-network v0.20.0.

Namespace#

Network#

The object namespace exposing the network connectivity APIs, backed by the native Network module. Available on both iOS and Android.

TypeScript
export const Network: {
  getState(): Promise<NetworkState>;
  isAvailable(): boolean;
} as const;

Import it directly:

TypeScript
import { Network } from '@sigx/lynx-network';

Functions#

Network.getState#

Returns a single async snapshot of the current network connectivity state. This is a one-shot call — there is no subscription stream. Available on both platforms.

TypeScript
getState(): Promise<NetworkState>

Returns — a Promise resolving to a NetworkState describing connectivity, transport type, and internet reachability.

Platform notes

  • iOS reads the latest path cached by NWPathMonitor. isInternetReachable mirrors isConnected (it is never an independent reachability probe and is never null). iOS never reports 'bluetooth' as the transport type.
  • Android reads ConnectivityManager. On API 23+ isInternetReachable reflects the NET_CAPABILITY_INTERNET capability; on older APIs it mirrors isConnected. Android can report 'bluetooth'.

Network.isAvailable#

Returns whether the native Network module is registered in the current build. Use it to guard getState() in builds where the module may not be linked. Available on both platforms.

TypeScript
isAvailable(): boolean

Returnstrue if the native Network module is present, otherwise false.

Types#

ConnectionType#

Union of possible active network transport types. Available on both platforms.

TypeScript
export type ConnectionType =
  | 'wifi'
  | 'cellular'
  | 'ethernet'
  | 'bluetooth'
  | 'none'
  | 'unknown';

Platform notes'bluetooth' is only ever produced on Android. iOS resolves the type in the order Wi-Fi, cellular, ethernet; if the path is satisfied but matches none of these it returns 'unknown', and 'none' when not satisfied.

NetworkState#

Snapshot shape returned by Network.getState(), describing connectivity, transport type, and internet reachability. Available on both platforms.

TypeScript
export interface NetworkState {
  isConnected: boolean;
  type: ConnectionType;
  isInternetReachable: boolean | null;
}

Fields

  • isConnected — whether the device currently has an active network connection.
  • type — the active transport, a ConnectionType.
  • isInternetReachable — whether the internet is actually reachable. null means the OS has not confirmed reachability (for example on a captive-portal Wi-Fi); treat it as "probably yes". The type permits null, though the current iOS implementation mirrors isConnected and Android sets a concrete boolean.