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-nitro-sensors

v0.1.6

Published

React Native Nitro sensor APIs for Android and iOS

Readme

react-native-nitro-sensors

Instance-based Nitro sensor APIs for Android and iOS.

Hooks

import { useAccelerometer } from 'react-native-nitro-sensors'

function AccelerometerValues() {
  const { reading, error, isAvailable, isObserving } = useAccelerometer({
    intervalMs: 16,
  })

  if (!isAvailable) return null
  if (error != null) return <Text>{error.message}</Text>

  return (
    <Text>
      {isObserving && reading != null
        ? `${reading.x}, ${reading.y}, ${reading.z}`
        : 'Waiting for accelerometer...'}
    </Text>
  )
}

Available hooks:

  • useAccelerometer(options)
  • useBarometer(options)
  • useDeviceMotion(options)
  • useGyroscope(options)
  • useMagnetometer(options)
  • useLightSensor(options)
  • usePedometer(options)

Hooks start observing by default and stop when the component unmounts. Pass isEnabled: false to keep a hook idle until your app is ready to observe. options.intervalMs is optional and uses the same native sampling behavior as startObserving.

const pedometer = usePedometer({
  isEnabled: hasPhysicalActivityPermission,
})

Hook errors are exposed through error as a JavaScript Error. Platform preconditions still apply; for example, Android pedometer hooks need the same Physical activity permission as the instance API before observation starts.

Expo Config Plugin

Add the plugin to your Expo config before running prebuild:

{
  "expo": {
    "plugins": [
      [
        "react-native-nitro-sensors",
        {
          "motionPermission": "Allow $(PRODUCT_NAME) to access your device motion."
        }
      ]
    ]
  }
}

The plugin adds NSMotionUsageDescription on iOS and android.permission.ACTIVITY_RECOGNITION on Android. If motionPermission is omitted, the plugin preserves an existing NSMotionUsageDescription value or uses a default message.

Android apps still need to request the Physical activity runtime permission before starting pedometer updates on Android 10/API 29 and newer.

Instance API

import { Sensors } from 'react-native-nitro-sensors'

const accelerometer = Sensors.createAccelerometer()

if (accelerometer.isAvailable) {
  accelerometer.startObserving(
    { intervalMs: 16 },
    (reading) => {
      console.log(reading.x, reading.y, reading.z, reading.timestampMs)
    },
    (error) => {
      console.error(error.message)
    }
  )
}

Available sensors:

  • Accelerometer: Android and iOS
  • Barometer: Android and iOS
  • DeviceMotion: Android and iOS
  • Gyroscope: Android and iOS
  • Magnetometer: Android and iOS
  • LightSensor: Android only
  • Pedometer: Android and iOS

iOS apps must include NSMotionUsageDescription in their Info.plist before starting CoreMotion-backed sensors such as Barometer or Pedometer on a real device.

Android apps that use Pedometer must declare android.permission.ACTIVITY_RECOGNITION and request the Physical activity runtime permission before starting pedometer updates on Android 10/API 29 and newer.

Each sensor object keeps native observation state and exposes isAvailable, isObserving, startObserving(options, onReading, onError), and stopObserving(). Starting an unsupported sensor throws instead of failing silently.

options.intervalMs is optional. Continuous sensors use it as a sampling-period hint and default to 16 ms; platform-driven sensors may ignore it when the native API does not support caller-controlled intervals.