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

@bglocation/react-native

v1.1.1

Published

React Native module for continuous background location tracking on iOS and Android

Readme

@bglocation/react-native

React Native module for continuous background location tracking on iOS and Android.

Part of the bglocation.dev ecosystem — identical API surface as @bglocation/capacitor.

Status

Bridge complete — native bridges (iOS + Android) are fully wired to bglocation-native-core. All 14 API methods and 11 events are implemented. Not yet published to npm — pending manual device testing.

Features

  • Continuous background GPS tracking (iOS + Android)
  • Configurable distance filter (fixed or speed-adaptive auto mode)
  • Heartbeat timer for stationary detection
  • Native HTTP POST with offline SQLite buffer + retry
  • Geofencing (up to 20 regions, enter/exit/dwell)
  • RSA-2048-SHA256 license validation (perpetual + update gating)
  • Trial mode (30 min + 1h cooldown)
  • Battery optimization detection (Android)
  • Approximate location detection (iOS 14+)
  • Mock location detection (Android)
  • Debug mode with verbose logging

Requirements

  • React Native >= 0.76 (New Architecture / TurboModules)
  • iOS >= 15.0
  • Android API >= 26 (Android 8.0)

Installation

npm install @bglocation/react-native
# or
yarn add @bglocation/react-native

Expo (Dev Build / CNG)

Add the plugin to your app.json / app.config.js:

{
  "expo": {
    "plugins": [
      [
        "@bglocation/react-native",
        {
          "locationWhenInUsePermission": "This app uses your location to track your position.",
          "locationAlwaysPermission": "This app uses your location in the background to continuously track your position."
        }
      ]
    ]
  }
}

Then rebuild: npx expo prebuild --clean && npx expo run:ios

Note: This plugin requires native code and does not work in Expo Go.

Bare React Native — iOS

cd ios && pod install

Bare React Native — Android

No additional setup required — auto-linking handles everything.

Quick Start

import {
  configure,
  start,
  stop,
  addListener,
  requestPermissions,
} from '@bglocation/react-native';

// 1. Request permissions
await requestPermissions({ permissions: ['location'] });
await requestPermissions({ permissions: ['backgroundLocation'] });

// 2. Configure
const result = await configure({
  distanceFilter: 'auto',
  heartbeatInterval: 15,
  debug: true,
  http: {
    url: 'https://api.example.com/locations',
    headers: { Authorization: 'Bearer TOKEN' },
  },
});

console.log('License mode:', result.licenseMode);

// 3. Listen for events
const sub = addListener('onLocation', (location) => {
  console.log('Location:', location.latitude, location.longitude);
});

// 4. Start tracking
await start();

// 5. Stop tracking
await stop();
sub.remove();

API

The API is identical to @bglocation/capacitor. See the full API Reference.

Methods

| Method | Description | |--------|-------------| | checkPermissions() | Check current location permission status | | requestPermissions(options?) | Request location permissions | | configure(options) | Configure the location service + validate license | | start() | Start background tracking | | stop() | Stop background tracking | | getState() | Get current tracking state | | getCurrentPosition(options?) | One-shot location request | | addGeofence(geofence) | Add a geofence region | | addGeofences(options) | Batch add geofences (atomic) | | removeGeofence(options) | Remove a geofence by identifier | | removeAllGeofences() | Remove all geofences | | getGeofences() | Get registered geofences | | checkBatteryOptimization() | Check battery optimization state | | requestBatteryOptimization() | Open battery optimization settings | | addListener(event, handler) | Subscribe to events | | removeAllListeners() | Remove all event listeners |

Events

| Event | Description | |-------|-------------| | onLocation | Location update | | onHeartbeat | Stationary heartbeat | | onProviderChange | GPS/Network provider change | | onHttp | HTTP POST response | | onDebug | Debug log message | | onBatteryWarning | Battery optimization warning (Android) | | onAccuracyWarning | Approximate location warning (iOS 14+) | | onMockLocation | Mock location detected (Android) | | onPermissionRationale | Permission rationale needed (Android 11+) | | onTrialExpired | Trial period expired | | onGeofence | Geofence transition (enter/exit/dwell) |

License

ELv2 (Elastic License v2)

Migration from Capacitor

Change the import and remove Capacitor-specific patterns:

- import { BackgroundLocation } from '@bglocation/capacitor';
+ import { configure, start, stop, addListener } from '@bglocation/react-native';

- const result = await BackgroundLocation.configure({ ... });
+ const result = await configure({ ... });

- const handle = await BackgroundLocation.addListener('onLocation', handler);
- handle.remove();
+ const sub = addListener('onLocation', handler);
+ sub.remove();

The configuration object, event payloads, and types are identical — only the import path and function-based API style differ.