# react-native-get-location

> ⚛ Simple to use React Native library to get device location for Android and iOS.

Latest version **6.0.1** (published 2025-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-get-location
pnpm add react-native-get-location
yarn add react-native-get-location
bun add react-native-get-location
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 6.0.1 |
| Published | 2025-12-09 |
| First published | 2019-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 89.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 261 |
| Author | Douglas Nassif Roma Junior |
| Maintainers | douglasjunior |
| Keywords | react-native, android, ios, geolocation, location, gps |

## Links

- npm: https://www.npmjs.com/package/react-native-get-location
- Repository: https://github.com/douglasjunior/react-native-get-location
- Issues: https://github.com/douglasjunior/react-native-get-location/issues
- npm.io page: https://npm.io/package/react-native-get-location

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 6.0.1 (latest) — 2025-12-09
- 6.0.0 — 2025-09-22
- 5.0.0 — 2024-08-05
- 4.0.1 — 2023-12-14
- 4.0.0 — 2023-08-19
- 3.0.1 — 2023-03-06
- 3.0.0 — 2023-03-02
- 2.2.1 — 2021-12-03
- 2.2.0 — 2021-12-03
- 2.1.2 — 2021-08-02
- 2.1.1 — 2021-05-26
- 2.1.0 — 2021-03-26
- 2.0.0 — 2020-12-09
- 1.4.3 — 2020-08-08
- 1.4.2 — 2019-12-24
- … 18 more at https://npm.io/package/react-native-get-location/versions

## README

# React-Native Get Location

[![License MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/douglasjunior/react-native-get-location/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/react-native-get-location.svg)](https://www.npmjs.com/package/react-native-get-location)
[![npm downloads](https://img.shields.io/npm/dt/react-native-get-location.svg)](https://www.npmjs.com/package/react-native-get-location?activeTab=versions)

⚛ Simple to use React Native library to get native device location for Android and iOS.

## Requirements

- React Native >= 0.71.0
- iOS >= 14.0
- Android >= API 21

## Install

Install dependency package
```bash
yarn add react-native-get-location
```
Or
```bash
npm i -S react-native-get-location
```

Go to the folder **your-project/ios** and run `pod install`, and you're done. 

## Android post install

For Android you need to define the location permissions on `AndroidManifest.xml`.

```xml
<!-- Define ACCESS_FINE_LOCATION if you will use enableHighAccuracy=true  -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<!-- Define ACCESS_COARSE_LOCATION if you will use enableHighAccuracy=false  -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
```

## iOS post install

You need to define the permission [NSLocationWhenInUseUsageDescription](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW26) on `Info.plist`.

```xml
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs to get your location...</string>
```

## Usage

There is only one function that you need to use to get the user's current location.

```js
import GetLocation from 'react-native-get-location'

GetLocation.getCurrentPosition({
    enableHighAccuracy: true,
    timeout: 60000,
})
.then(location => {
    console.log(location);
})
.catch(error => {
    const { code, message } = error;
    console.warn(code, message);
})
```

For more details, see the [Sample Project](https://github.com/douglasjunior/react-native-get-location/blob/master/Sample/App.tsx).

## API

### function `GetLocation.getCurrentPosition(LocationConfig)`

**Parameters:**
   - [`LocationConfig`](#object-locationconfig): Configuration object to determine how to get the user current location.

**Return:**
   - `Promise<`[`Location`](#object-location)`>`: Promise thats resolve to a Location object.

### Object `LocationConfig`

**Properties:**
   - `enableHighAccuracy`: Set `true` to use 'fine location' (GPS) our `false` to use 'course location' (Wifi, Bluetooth, 3G). Default: `false`
   - `timeout`: The max time (in milliseconds) that you want to wait to receive a location. Default: `60000` (60 seconds)
   - `rationale?`: (Android only) See the [React Native docs](https://reactnative.dev/docs/permissionsandroid#request).

### Object `Location`

**Properties:**
   - `latitude`: The latitude, in degrees.
   - `longitude`: The longitude, in degrees.
   - `altitude`: The altitude if available, in meters above the WGS 84 reference ellipsoid.
   - `accuracy`: The estimated horizontal accuracy of this location, radial, in meters.
   - `speed`: The speed if it is available, in meters/second over ground.
   - `time`: The UTC time of this fix, in milliseconds since January 1, 1970.
   - `bearing`: *(Android only)* The bearing, in degrees.
   - `provider`: *(Android only)* The name of the provider that generated this fix.
   - `verticalAccuracy`: *(iOS only)* The vertical accuracy of the location. Negative if the altitude is invalid.
   - `course`: *(iOS only)* The course of the location in degrees true North. Negative if course is invalid. (0.0 - 359.9 degrees, 0 being true North)

### Error codes

|Code|Message|
|-|-|
|`CANCELLED`|Location cancelled by user or by another request|
|`UNAVAILABLE`|Location service is disabled or unavailable|
|`TIMEOUT`|Location request timed out|
|`UNAUTHORIZED`|Location permission denied by the user|

## Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions use the [issues](https://github.com/douglasjunior/react-native-get-location/issues).

<a href="https://www.patreon.com/douglasjunior"><img src="http://i.imgur.com/xEO164Z.png" alt="Become a Patron!" width="200" /></a>
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/douglasnassif)

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=douglasjunior/react-native-get-location&type=Date)](https://star-history.com/#douglasjunior/react-native-get-location)

## License

```
The MIT License (MIT)

Copyright (c) 2019 Douglas Nassif Roma Junior
```

See the full [license file](https://github.com/douglasjunior/react-native-get-location/blob/master/LICENSE).

---
_Source: https://npm.io/package/react-native-get-location · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
