@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();