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.
export const Network: {
getState(): Promise<NetworkState>;
isAvailable(): boolean;
} as const;
Import it directly:
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.
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.isInternetReachablemirrorsisConnected(it is never an independent reachability probe and is nevernull). iOS never reports'bluetooth'as the transport type. - Android reads
ConnectivityManager. On API 23+isInternetReachablereflects theNET_CAPABILITY_INTERNETcapability; on older APIs it mirrorsisConnected. 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.
isAvailable(): boolean
Returns — true if the native Network module is present, otherwise false.
Types
ConnectionType
Union of possible active network transport types. Available on both platforms.
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.
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, aConnectionType.isInternetReachable— whether the internet is actually reachable.nullmeans the OS has not confirmed reachability (for example on a captive-portal Wi-Fi); treat it as "probably yes". The type permitsnull, though the current iOS implementation mirrorsisConnectedand Android sets a concrete boolean.
