Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Get correctly `localhost` on Android emulator for React Native.

License

Notifications You must be signed in to change notification settings

connectedcars/rn-host-detect

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rn-host-detect

Get correctly localhost on Android emulator for React Native

On Android emulator, if you want to connect any servers of local, you will need run adb reverse on your terminal. This module made it easier, you can get the localhost IP of host machine directly (10.0.2.2, Genymotion: 10.0.3.2).

This was done in the following projects:

That's why you don't need adb reverse when you're using these modules on Android emulator.

Installation

$ npm i rn-host-detect --save-dev

Usage

const getHostForRN = require('rn-host-detect')

// '10.0.2.2' or '10.0.3.2' on Android
getHostForRN('localhost')

// '192.168.1.111', only convert localhost (or 127.0.0.1) to host IP
getHostForRN('192.168.1.111')

License

MIT

About

Get correctly `localhost` on Android emulator for React Native.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%