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-barometer

v2.0.0

Published

Obtain barometric and altitude readings for both Android and iOS

Downloads

731

Readme

react-native-barometer

Provides barometric and altitude information for React Native apps on iOS and Android.

New Architecture only (v2.0.0+)
This library supports only the React Native New Architecture (Turbo Modules). It does not work with the legacy bridge.

Requirements (v2.0.0+)

  • React Native >=0.84 <0.86 with React 19
  • New Architecture only — not compatible with the legacy bridge
  • iOS 15.1+
  • Android API 24+ (minSdk 24)

Legacy bridge / React Native 0.59–0.83 apps should stay on v1.x.

Getting started

yarn add react-native-barometer
# or
npm install react-native-barometer --save

Installation

From React Native 0.60 onward, autolinking handles native setup.

iOS: run pod install in your ios directory after installing the package. The library ships a podspec (react-native-barometer.podspec); you do not need to add a manual pod line when using autolinking.

Add Core Motion usage text to your app’s Info.plist (required for CMAltimeter on iOS):

<key>NSMotionUsageDescription</key>
<string>Your explanation of why the app reads barometric pressure and altitude.</string>

Android: no extra steps beyond a clean rebuild.

Example app

This repository includes an example app under example/ (React Native 0.85, New Architecture):

cd example
npm install
cd ios && bundle exec pod install && cd ..
npx react-native run-ios
# or
npx react-native run-android

Usage

Call isSupported() before watch() on devices where a barometer may be absent.

Example

import Barometer, {STANDARD_PRESSURE_HPA} from 'react-native-barometer';

const supported = await Barometer.isSupported();
if (supported) {
  const watchId = Barometer.watch(payload => {
    console.log(payload.pressure, payload.relativeAltitude);
  });
}

Payload fields

| Field | Description | | ----- | ----------- | | timestamp | Sample time (ms since Unix epoch) | | pressure | Filtered air pressure in hPa (EMA-smoothed on both platforms) | | altitudeASL | Altitude in metres from the standard atmosphere (1013.25 hPa) | | altitude | Altitude in metres using setLocalPressure() as sea-level reference | | relativeAltitude | Change since observing started — Core Motion on iOS; computed baseline on Android | | verticalSpeed | Rate of change of altitudeASL over the emit interval (m/s), zero on the first sample |

setInterval(ms) is clamped to a minimum of 50 ms. setLocalPressure(hPa) ignores non-positive values and falls back to 1013.25 hPa.

TypeScript types are available via index.d.ts (BarometerPayload, etc.).

Methods

Summary


Details

isSupported()

Before using, check to see if barometric updates are supported on the device.

const isSupported = await Barometer.isSupported();

setInterval()

Optionally request an update interval in ms. The default update rate is (approx) 200ms, i.e. 5Hz.

// request updates once every second
Barometer.setInterval(1000);

setLocalPressure()

The altitude event contains two altitudes. The first is the standard atmosphere altitude based upon the standard atmospheric pressure of 1013.25hPa. The second is an altitude based upon a pressure that you can configure. You typically use this to calibrate the altitude to a reference altitude, for example the field elevation of an airport.

// set the local pressure to 985hPa
Barometer.setLocalPressure(985);

watch()

Barometer.watch(success);

Invokes the success callback whenever the pressure or altitude changes. The payload delivered via the callback is defined in the example below.

Returns a watchId (number).

Parameters:

| Name | Type | Required | Description | | ------- | -------- | -------- | ----------- | | success | function | Yes | Invoked at a default interval of 5hz. This can be changed by using the setInterval method. |

Example:

const watchId = Barometer.watch(payload => {
  /*
  payload.timestamp - sample time in ms referenced to January 1, 1970 UTC
  payload.pressure - current air pressure in hPa
  payload.altitudeASL - altitude in metres based upon standard atmosphere
  payload.altitude - altitude in metres based upon the local pressure
  payload.relativeAltitude - change since observing started (see table above).
  payload.verticalSpeed - change in altitudeASL over the emit interval (m/s)
  */
});

clearWatch()

Barometer.clearWatch(watchID);

Parameters:

| Name | Type | Required | Description | | ------- | ------ | -------- | ------------------------------ | | watchID | number | Yes | Id as returned by watch(). |


stopObserving()

Barometer.stopObserving();

Stops observing for all barometric updates.

In addition, it removes all listeners previously registered.

Note that this method does nothing if the Barometer.watch(successCallback) method has not previously been called.