# rn-host-detect

> Get correctly localhost on Android emulator for React Native

Latest version **1.2.0** (published 2019-11-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install rn-host-detect
pnpm add rn-host-detect
yarn add rn-host-detect
bun add rn-host-detect
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-11-03 |
| First published | 2017-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/rn-host-detect) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Jhen |
| Maintainers | jhen0409 |

## Links

- npm: https://www.npmjs.com/package/rn-host-detect
- Repository: https://github.com/jhen0409/rn-host-detect
- Homepage: https://github.com/jhen0409/rn-host-detect#readme
- Issues: https://github.com/jhen0409/rn-host-detect/issues
- npm.io page: https://npm.io/package/rn-host-detect

## Recent versions

- 1.2.0 (latest) — 2019-11-03
- 1.1.6 — 2019-11-02
- 1.1.5 — 2018-08-14
- 1.1.4 — 2018-07-21
- 1.1.3 — 2017-03-15
- 1.1.2 — 2017-03-15
- 1.1.1 — 2017-03-13
- 1.1.0 — 2017-03-13
- 1.0.1 — 2017-01-27
- 1.0.0 — 2017-01-27

## README

# 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:

* [remote-redux-devtools](https://github.com/zalmoxisus/remote-redux-devtools/blob/fbb169173c235eceb136a02a52c6f36b64297910/src/utils/reactNative.js)
* [reactotron-react-native](https://github.com/infinitered/reactotron/blob/f5de09955b870a90cc772bf6c5139ef8e3ecbbba/packages/reactotron-react-native/src/get-host.js)

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

## Installation

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

## Usage

```js
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](LICENSE.md)

---
_Source: https://npm.io/package/rn-host-detect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
