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

v1.0.15

Published

High-performance sensor access for React Native built with Nitro Modules. Accelerometer, Gyroscope, Magnetometer, Device Motion, Barometer, and Pedometer with zero-bridge JSI-powered native access.

Readme

react-native-nitro-sensors-kit

A React Native Nitro Module providing high-performance, zero-bridge access to device sensors:

  • 📐 Accelerometer — Raw acceleration in m/s²
  • 🌀 Gyroscope — Angular velocity in rad/s
  • 🧭 Magnetometer — Magnetic field strength in µT
  • 🎯 Device Motion — OS-fused attitude, gravity, and user acceleration
  • 🌤️ Barometer — Atmospheric pressure and relative altitude
  • 🚶 Pedometer — Step counting, distance, pace, cadence, and floors

Built with Nitro Modules for direct JSI-powered native sensor access — no bridge, no serialization overhead.


[!IMPORTANT]

  • Tested on React Native 0.81+ with Nitro Modules.
  • Sensors return real data on physical devices only — simulators/emulators return zeros or are unavailable.
  • Pedometer requires iOS 14+ and Android API 29+ for runtime permissions.

📦 Installation

npm install react-native-nitro-sensors-kit react-native-nitro-modules
cd ios && pod install

Demo


Configuration

iOS

Add to your Info.plist (required for Pedometer only):

<key>NSMotionUsageDescription</key>
<string>This app uses motion sensors to track your steps and activity</string>

No setup needed for Accelerometer, Gyroscope, Magnetometer, Device Motion, or Barometer.

Android

Add to your AndroidManifest.xml (required for Pedometer only):

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

No setup needed for the other 5 sensors.


🧠 Overview

| Sensor | iOS API | Android API | Permission | | ----------------- | ----------------- | -------------------------------------- | --------------------------------------------------- | | Accelerometer | CMMotionManager | TYPE_ACCELEROMETER | None | | Gyroscope | CMMotionManager | TYPE_GYROSCOPE | None | | Magnetometer | CMMotionManager | TYPE_MAGNETIC_FIELD | None | | Device Motion | CMDeviceMotion | TYPE_ROTATION_VECTOR + fused sensors | None | | Barometer | CMAltimeter | TYPE_PRESSURE | None | | Pedometer | CMPedometer | TYPE_STEP_COUNTER | NSMotionUsageDescription / ACTIVITY_RECOGNITION |


⚙️ Usage

With Hooks (Recommended)

import React, { useState } from 'react';
import { View, Text, Button, ScrollView, StyleSheet } from 'react-native';
import {
  useAccelerometer,
  useGyroscope,
  useMagnetometer,
  useDeviceMotion,
  useBarometer,
  usePedometer,
} from 'react-native-nitro-sensors-kit';

export default function App() {
  const [active, setActive] = useState(false);

  const accel = useAccelerometer(100, active);
  const gyro = useGyroscope(100, active);
  const mag = useMagnetometer(100, active);
  const motion = useDeviceMotion(100, active);
  const baro = useBarometer(active);
  const pedo = usePedometer(active);

  return (
    <ScrollView style={styles.container}>
      <Text style={styles.title}>Nitro Sensors</Text>

      <Button
        title={active ? 'Stop All Sensors' : 'Start All Sensors'}
        onPress={() => setActive((p) => !p)}
      />

      <Text style={styles.section}>Accelerometer (m/s²)</Text>
      <Text>X: {accel.data?.x.toFixed(3)}</Text>
      <Text>Y: {accel.data?.y.toFixed(3)}</Text>
      <Text>Z: {accel.data?.z.toFixed(3)}</Text>

      <Text style={styles.section}>Gyroscope (rad/s)</Text>
      <Text>X: {gyro.data?.x.toFixed(3)}</Text>
      <Text>Y: {gyro.data?.y.toFixed(3)}</Text>
      <Text>Z: {gyro.data?.z.toFixed(3)}</Text>

      <Text style={styles.section}>Magnetometer (µT)</Text>
      <Text>X: {mag.data?.x.toFixed(3)}</Text>
      <Text>Y: {mag.data?.y.toFixed(3)}</Text>
      <Text>Z: {mag.data?.z.toFixed(3)}</Text>

      <Text style={styles.section}>Device Motion</Text>
      <Text>Pitch: {motion.data?.attitude?.pitch.toFixed(3)}</Text>
      <Text>Roll: {motion.data?.attitude?.roll.toFixed(3)}</Text>
      <Text>Yaw: {motion.data?.attitude?.yaw.toFixed(3)}</Text>

      <Text style={styles.section}>Barometer</Text>
      <Text>Pressure: {baro.data?.pressure.toFixed(1)} hPa</Text>
      <Text>Rel. Altitude: {baro.data?.relativeAltitude.toFixed(2)} m</Text>

      <Text style={styles.section}>Pedometer</Text>
      <Text>Steps: {pedo.data?.steps ?? '—'}</Text>
      <Text>Distance: {pedo.data?.distance ?? '—'} m</Text>
      <Text>Permission: {pedo.permissionStatus}</Text>
      {pedo.permissionStatus === 'notDetermined' && (
        <Button title="Request Permission" onPress={pedo.requestPermission} />
      )}
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 20 },
  title: { fontSize: 28, fontFamily: 'System', marginBottom: 16 },
  section: { fontSize: 16, fontFamily: 'System', marginTop: 16, color: '#888' },
});

Direct API (No Hooks)

import { accelerometer, pedometer } from 'react-native-nitro-sensors-kit';

// Accelerometer — no permissions needed
accelerometer.interval = 50; // 50ms = 20Hz
accelerometer.onUpdate = (data) => {
  console.log(`x: ${data.x}, y: ${data.y}, z: ${data.z}`);
};
accelerometer.start();

// Pedometer — requires permission
const status = await pedometer.requestPermission();
if (status === 'granted') {
  pedometer.onUpdate = (data) => {
    console.log(`Steps: ${data.steps}, Distance: ${data.distance}m`);
  };
  pedometer.start();
}

// Query historical steps (iOS only)
const history = await pedometer.queryHistoricalData(
  Date.now() - 86400000, // 24h ago
  Date.now()
);
console.log(`Steps in last 24h: ${history.steps}`);

// Clean up
accelerometer.stop();
pedometer.stop();

🧩 API Reference

Hooks

| Hook | Params | Returns | | -------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------ | | useAccelerometer(interval?, active?) | number, boolean | { data, isAvailable, isActive } | | useGyroscope(interval?, active?) | number, boolean | { data, isAvailable, isActive } | | useMagnetometer(interval?, active?) | number, boolean | { data, isAvailable, isActive } | | useDeviceMotion(interval?, active?) | number, boolean | { data, isAvailable, isActive } | | useBarometer(active?) | boolean | { data, isAvailable, isActive } | | usePedometer(active?) | boolean | { data, isAvailable, isActive, permissionStatus, requestPermission, checkPermission, queryHistoricalData } |

Data Types

AccelerometerData / GyroscopeData / MagnetometerData

{
  x: number;
  y: number;
  z: number;
  timestamp: number;
}

DeviceMotionData

{
  attitude: {
    pitch: number;
    roll: number;
    yaw: number;
  }
  rotationRate: {
    x: number;
    y: number;
    z: number;
  }
  userAcceleration: {
    x: number;
    y: number;
    z: number;
  }
  gravity: {
    x: number;
    y: number;
    z: number;
  }
  heading: number; // degrees, -1 if unavailable
  timestamp: number;
}

BarometerData

{
  pressure: number; // hPa (mbar)
  relativeAltitude: number; // meters since start()
  timestamp: number;
}

PedometerData

{
  steps: number;
  distance: number; // meters, -1 if unavailable
  currentPace: number; // s/m, iOS only, -1 if unavailable
  currentCadence: number; // steps/s, iOS only, -1 if unavailable
  floorsAscended: number; // iOS only, -1 if unavailable
  floorsDescended: number; // iOS only, -1 if unavailable
  timestamp: number;
}

PermissionStatus

'granted' | 'denied' | 'restricted' | 'notDetermined';

🧩 Platform Differences

| Feature | iOS | Android | | --------------------------- | ----------------------- | ------------------------------- | | Pedometer distance | ✅ | ❌ (-1) | | Pedometer pace/cadence | ✅ | ❌ (-1) | | Pedometer floors | ✅ | ❌ (-1) | | Historical step queries | ✅ CMPedometer | ❌ Not supported | | Barometer relative altitude | ✅ Native | ✅ Computed from pressure delta | | Device Motion heading | ✅ Magnetic north | ❌ (-1) | | Device Motion fusion | Single CMDeviceMotion | 4 sensors fused manually |


🧩 Supported Platforms

| Platform | Status | | ----------------------------- | ---------------------------- | | iOS (physical device) | ✅ Supported | | Android (physical device) | ✅ Supported | | iOS Simulator | ⚠️ Most sensors return zeros | | Android Emulator | ⚠️ Most sensors unavailable |


🤝 Contributing

PRs welcome!


🪪 License

MIT © Gautham Vijayan


Made with ❤️ and Nitro Modules