Expo

Documentation

NetInfo

This API allows you to get information about connection type and connection quality.
Platform Compatibility
Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorWeb

To install this API in a managed or bare React Native app, run expo install @react-native-community/netinfo. In bare apps, make sure you also follow the react-native-netinfo linking and configuration instructions.

To import this library, use:
import NetInfo from '@react-native-community/netinfo';
If you want to grab information about the network connection just once, you can use:
NetInfo.fetch().then(state => {
  console.log('Connection type', state.type);
  console.log('Is connected?', state.isConnected);
});
Or, if you'd rather subscribe to updates about the network state (which then allows you to run code/perform actions anytime the network state changes) use:
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();
Read the react-native-netinfo docs for more information on the API and usage.