1

I want to get the local IP address of the mobile on React Native (Expo). I stumbled upon various libraries like react-native-network-info and expo-network but none seem to work as the former doesn't work with expo and the later cannot get the local IP address. Is there any other way of doing it? (I need the managed workflow)

avkat
  • 101
  • 1
  • 8
  • 1
    Do you mean public IP or private IP? For public, you may simply knock on https://checkip.amazonaws.com – Yevhen Horbunkov Dec 03 '20 at 08:50
  • 1
    Javascript / browser **does not** have access to the LAN IP address of the machine. There used to be a [partial solution](https://stackoverflow.com/a/26850789/372172), but [browsers have since got smarter](https://stackoverflow.com/a/32841043/372172). – Koala Yeung Dec 03 '20 at 09:00
  • @KoalaYeung I want it in react native app. It is possible in bare react-native but with expo, I cannot find the solution – avkat Dec 03 '20 at 09:02
  • Check out [this answer](https://stackoverflow.com/a/38595963/372172). – Koala Yeung Dec 03 '20 at 09:14
  • @KoalaYeung Doesn't work with expo – avkat Dec 03 '20 at 10:11
  • According to [this](https://docs.expo.io/workflow/using-libraries/#determining-third-party-library-compatibility), since react-native-network-info is a in the [React Native Directory](https://reactnative.directory/?search=react-native-network-info), it is not part of the Expo SDK. You need to [eject to bare workflow](https://docs.expo.io/workflow/customizing/) to use it. – Koala Yeung Dec 03 '20 at 10:19
  • Checked the source of [react-native-network-info](https://github.com/pusherman/react-native-network-info/). It uses native bindings to get the results. I guess you probably cannot do it with Expo SDK alone. Sorry. – Koala Yeung Dec 03 '20 at 14:05

0 Answers0