title: How to check for an internet connection in an Expo React Native app?
body: <p>I have an Expo app using the <a href="https://docs.expo.io/versions/latest/introduction/managed-vs-bare/" rel="noreferrer">Managed workflow</a>. The app needs to check whether an internet connection is available.</p>
  
  <ul>
  <li>I can't <code>import { NetInfo } from 'react-native'</code> because <a href="https://facebook.github.io/react-native/docs/netinfo.html" rel="noreferrer">that's deprecated</a>.</li>
  <li>I can't use <a href="https://github.com/react-native-community/react-native-netinfo" rel="noreferrer">react-native-community/react-native-netinfo</a> because that uses native libraries, and you can't do that with an Expo managed app.</li>
  <li>I could eject, in order to use the above, but it doesn't seem like I should need to do that just to check if there's an internet connection.</li>
  <li>I can't use <a href="https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine" rel="noreferrer"><code>navigator.onLine</code></a> because that global variable doesn't seem to be available.</li>
  <li>I could make a trivial HTTP request to Google or my own server or whatever, and see if I get a response, but that only tests a connection to one site, and also it takes time and uses bandwidth.</li>
  </ul>
  
  <p>What should I do?</p>