npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-geolocation-provider

v1.2.1

Published

A geolocation provider specifically for react native

Readme

react-native-geolocation-provider

npm version npm downloads license

Native Core Location and Android LocationManager bindings for React Native.

Why this package exists

This package is intended as a maintained replacement for @react-native-community/geolocation. The community package has seen limited maintenance for modern React Native versions, while many applications still need a small native geolocation API that works with current Android, iOS, and React Native New Architecture tooling.

It is implemented as a React Native TurboModule using codegen, rather than the deprecated legacy bridge module used by older geolocation packages. The JavaScript API keeps the familiar getCurrentPosition, watchPosition, clearWatch, and stopObserving methods so existing usage can be migrated with minimal application changes.

Installation

yarn add react-native-geolocation-provider
cd ios && pod install

The application remains responsible for deciding when to request runtime location permission. Add NSLocationWhenInUseUsageDescription to the iOS application Info.plist. Android coarse and fine location permissions are merged from this library's manifest.

Repository structure

This project is a monorepo managed using Yarn workspaces. It contains the library package at the repository root and the React Native example app in example.

Example app

The example app provides a simple manual test screen for the native module. It includes separate buttons for one-shot current location requests and continuous watch updates, plus an on-screen log panel for positions and errors.

To run it:

yarn
yarn example android

For iOS, install pods before running:

cd example/ios && pod install
cd ../..
yarn example ios

The example app does not request runtime location permission automatically on startup. Tap its permission button before testing, or grant location permission from device settings. On real devices, the first high-accuracy GPS fix can still take several seconds, especially indoors. Keeping watchPosition active can warm the device location provider before a one-shot request.

Improvements over the community package

  • Uses React Native TurboModule/codegen rather than the old bridge module.
  • Uses current native Android and iOS location APIs directly.
  • Provides both promise and callback forms for getCurrentPosition.
  • Emits watcher updates immediately instead of filtering startup fixes in JS.
  • Supports Android interval, fastestInterval, and distanceFilter.
  • Stops native observation automatically when the final watcher is cleared.
  • Uses a 30 second default current-location timeout for slower GPS cold starts.

Current location

import { requestAuthorization } from 'react-native-geolocation-provider';

const status = await requestAuthorization();

requestAuthorization()

Requests location permission and resolves with granted, denied, restricted, or notDetermined. Location is not requested automatically by the library.

import { getCurrentPosition } from 'react-native-geolocation-provider';

const position = await getCurrentPosition({
  enableHighAccuracy: true,
  timeout: 30_000,
  maximumAge: 5_000,
});

The community geolocation callback signature is also supported:

getCurrentPosition(onLocation, onError, { enableHighAccuracy: true });

getCurrentPosition(options)

Returns a promise that resolves with one GeolocationPosition.

  • options.enableHighAccuracy uses GPS/high accuracy when available.
  • options.timeout sets the maximum wait time in milliseconds.
  • options.maximumAge allows a cached location within this age in milliseconds.

getCurrentPosition(success, error, options)

Callback-compatible form for replacing community geolocation calls.

  • success(position) receives the resolved GeolocationPosition.
  • error(error) receives a GeolocationError.
  • options supports the same fields as the promise form.

Location updates

import { clearWatch, watchPosition } from 'react-native-geolocation-provider';

const watchId = watchPosition(onLocation, onError, {
  enableHighAccuracy: true,
  distanceFilter: 5,
  interval: 1_000,
  fastestInterval: 500,
});

clearWatch(watchId);

watchPosition(success, error, options)

Starts native location observation and returns a numeric watch id.

  • success(position) is called for each native location update.
  • error(error) is called when native observation fails.
  • options.enableHighAccuracy uses GPS/high accuracy when available.
  • options.distanceFilter sets the minimum movement in metres.
  • options.interval sets the preferred Android update interval in milliseconds.
  • options.fastestInterval sets Android's fastest accepted interval in milliseconds.

clearWatch(id)

Stops the watcher matching the id returned by watchPosition. Native observation is stopped automatically when the final watcher is cleared.

stopObserving()

Stops all watchers and removes native location subscriptions.

API surface

Documented public methods are requestAuthorization, getCurrentPosition, watchPosition, clearWatch, and stopObserving. There are no additional public methods. Native event emitters are internal implementation details.

Positions contain W3C-style coords and millisecond timestamp values. Errors use codes 1 (permission), 2 (unavailable), and 3 (timeout).

License

MIT