Expo get device local ip-address

Viewed 1874

I'm developing a mobile application using Expo framework(react native).

I need to find the device's local IP address in order to connect to a specific device on the intranet.

Please guide me through this task.

Thanks

2 Answers

You can use Expo Network.getIpAddressAsync() which returns a Promise, so you need to resolve it first.

Here is an example:

import * as Network from 'expo-network';

const ipAlert = async () => {
  const ip = await Network.getIpAddressAsync()
  alert(ip);
};

ipAlert();
Related