Connection state through One.Network. Backed by NWPathMonitor on iOS, ConnectivityManager with a NetworkCallback on Android, and navigator.onLine with online/offline events on web.
import { One, useNetworkState } from 'one'import { Text } from 'react-native'
const state = await One.Network.getState()// { type: 'wifi', isConnected: true, isInternetReachable: true }
const subscription = One.Network.addStateListener((next) => { console.log(next.type)})subscription.remove()
function NetworkStatus() { const live = useNetworkState() return <Text>{live.type}</Text>}type is one of none, unknown, cellular, wifi, bluetooth, ethernet, wimax, vpn, or other. On web a live connection reports unknown, since browser connection types are unreliable.
The library manifest declares ACCESS_NETWORK_STATE (a normal install-time permission, merged into the app automatically).
Edit this page on GitHub.