@react-native-community/netinfo
allows you to get information about connection type and connection quality.Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
→
expo install @react-native-community/netinfo
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
import NetInfo from '@react-native-community/netinfo';
NetInfo.fetch().then(state => { console.log('Connection type', state.type); console.log('Is connected?', state.isConnected); });
const unsubscribe = NetInfo.addEventListener(state => { console.log('Connection type', state.type); console.log('Is connected?', state.isConnected); }); // To unsubscribe to these update, just use: unsubscribe();
ssid
property (available under state.details.ssid
), there are few additional configuration steps:Location.requestPermissionsAsync()
com.apple.developer.networking.wifi-info
entitlement to your app.json file under ios.entitlements
:"ios": { "entitlements": { "com.apple.developer.networking.wifi-info": "true" } }
expo build:ios