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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-device-thermal

v0.1.0

Published

react-native-device-thermal gives you real-time access to the device’s thermal state on both iOS and Android. Detect overheating early, prevent throttling, and keep your app running smoothly. Fast. Lightweight. TurboModules-powered.

Readme

react-native-device-thermal

Monitor the thermal state of your iOS and Android devices in real-time with React Native.

Features

  • 🌡️ Get current thermal state of the device
  • 📊 Receive real-time thermal state change events
  • 🔥 Cross-platform support (iOS 11+ and Android 10+)
  • ⚡ Built with TurboModules and the New Architecture
  • 📱 Supports both new and legacy React Native architectures
  • 🎯 Fully typed TypeScript API

Installation

npm install react-native-device-thermal

or

yarn add react-native-device-thermal

iOS

cd ios && pod install

Android

No additional steps required.

Platform Requirements

| Platform | Minimum Version | API | |----------|----------------|-----| | iOS | iOS 11.0 | NSProcessInfo.thermalState | | Android | Android 10 (API 29) | PowerManager.currentThermalStatus |

API

isThermalMonitoringAvailable()

Check if thermal monitoring is available on the current device.

function isThermalMonitoringAvailable(): Promise<boolean>

Returns: Promise<boolean> - true if available, false otherwise.

Example:

import { isThermalMonitoringAvailable } from 'react-native-device-thermal';

const isAvailable = await isThermalMonitoringAvailable();
console.log('Thermal monitoring available:', isAvailable);

getThermalState()

Get the current thermal state of the device.

function getThermalState(): Promise<ThermalState>

Returns: Promise<ThermalState> - The current thermal state.

Example:

import { getThermalState } from 'react-native-device-thermal';

const state = await getThermalState();
console.log('Current thermal state:', state); // 'nominal', 'fair', 'serious', 'critical', or 'unknown'

getThermalInfo()

Get detailed thermal information including the platform-specific state.

function getThermalInfo(): Promise<ThermalEvent>

Returns: Promise<ThermalEvent> - Detailed thermal information.

Example:

import { getThermalInfo } from 'react-native-device-thermal';

const info = await getThermalInfo();
console.log('Thermal info:', info);
// {
//   state: 'nominal',
//   platformState: 'THERMAL_STATUS_NONE', // Android
//   temperature: null
// }

addThermalStateListener()

Listen to thermal state changes in real-time.

function addThermalStateListener(
  listener: (event: ThermalEvent) => void
): EmitterSubscription

Parameters:

  • listener: Callback function that receives ThermalEvent when the thermal state changes.

Returns: EmitterSubscription - Subscription object with a remove() method.

Example:

import { addThermalStateListener } from 'react-native-device-thermal';

const subscription = addThermalStateListener((event) => {
  console.log('Thermal state changed:', event.state);
  console.log('Platform state:', event.platformState);
});

// Later, to stop listening:
subscription.remove();

Types

ThermalState

Normalized thermal states across platforms:

type ThermalState =
  | 'unknown'   // Unable to determine or not supported
  | 'nominal'   // Normal temperature
  | 'fair'      // Slightly elevated, no action needed
  | 'serious'   // High temperature, reduce performance
  | 'critical'  // Very high temperature, immediate action needed

ThermalEvent

type ThermalEvent = {
  state: ThermalState;        // Normalized state
  platformState: string;      // Platform-specific state string
  temperature?: number | null; // Temperature in Celsius (currently always null)
}

Platform-Specific States

iOS (NSProcessInfoThermalState)

| iOS State | Normalized State | Description | |-----------|-----------------|-------------| | NSProcessInfoThermalStateNominal | nominal | No thermal issues | | NSProcessInfoThermalStateFair | fair | Slightly elevated | | NSProcessInfoThermalStateSerious | serious | Thermal pressure, reduce work | | NSProcessInfoThermalStateCritical | critical | High thermal pressure, reduce work significantly |

Android (PowerManager.ThermalStatus)

| Android State | Normalized State | Description | |--------------|-----------------|-------------| | THERMAL_STATUS_NONE (0) | nominal | No thermal issues | | THERMAL_STATUS_LIGHT (1) | fair | Light thermal throttling | | THERMAL_STATUS_MODERATE (2) | fair | Moderate thermal throttling | | THERMAL_STATUS_SEVERE (3) | serious | Severe thermal throttling | | THERMAL_STATUS_CRITICAL (4) | critical | Critical thermal state | | THERMAL_STATUS_EMERGENCY (5) | critical | Emergency thermal state | | THERMAL_STATUS_SHUTDOWN (6) | critical | Device about to shutdown |

Usage Example

import React, { useState, useEffect } from 'react';
import { View, Text, Button } from 'react-native';
import {
  isThermalMonitoringAvailable,
  getThermalState,
  getThermalInfo,
  addThermalStateListener,
  type ThermalState,
  type ThermalEvent,
} from 'react-native-device-thermal';

export default function App() {
  const [isAvailable, setIsAvailable] = useState(false);
  const [thermalState, setThermalState] = useState<ThermalState>('unknown');
  const [isListening, setIsListening] = useState(false);

  useEffect(() => {
    checkAvailability();
  }, []);

  useEffect(() => {
    if (!isListening) return;

    const subscription = addThermalStateListener((event: ThermalEvent) => {
      console.log('Thermal state changed:', event);
      setThermalState(event.state);
    });

    return () => {
      subscription.remove();
    };
  }, [isListening]);

  const checkAvailability = async () => {
    const available = await isThermalMonitoringAvailable();
    setIsAvailable(available);
  };

  const fetchState = async () => {
    const state = await getThermalState();
    setThermalState(state);
  };

  const fetchInfo = async () => {
    const info = await getThermalInfo();
    console.log('Thermal info:', info);
    setThermalState(info.state);
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', padding: 20 }}>
      <Text>Available: {isAvailable ? 'Yes' : 'No'}</Text>
      <Text>State: {thermalState}</Text>

      <Button title="Get State" onPress={fetchState} />
      <Button title="Get Info" onPress={fetchInfo} />
      <Button
        title={isListening ? 'Stop Listening' : 'Start Listening'}
        onPress={() => setIsListening(!isListening)}
      />
    </View>
  );
}

Practical Use Cases

1. Performance Optimization

Reduce app workload when device is overheating:

const subscription = addThermalStateListener((event) => {
  if (event.state === 'serious' || event.state === 'critical') {
    // Reduce frame rate, disable animations, pause background tasks
    pauseHeavyOperations();
  } else if (event.state === 'nominal') {
    // Resume normal operations
    resumeHeavyOperations();
  }
});

2. User Notifications

Warn users about thermal issues:

const state = await getThermalState();

if (state === 'critical') {
  Alert.alert(
    'Device Overheating',
    'Your device is very hot. Consider closing some apps or letting it cool down.'
  );
}

3. Gaming & AR Apps

Adjust graphics quality based on thermal state:

addThermalStateListener((event) => {
  switch (event.state) {
    case 'nominal':
      setGraphicsQuality('ultra');
      break;
    case 'fair':
      setGraphicsQuality('high');
      break;
    case 'serious':
      setGraphicsQuality('medium');
      break;
    case 'critical':
      setGraphicsQuality('low');
      break;
  }
});

4. Video Recording Apps

Adjust video quality or stop recording:

addThermalStateListener((event) => {
  if (event.state === 'critical') {
    // Stop 4K recording, switch to 1080p
    downgradeVideoQuality();
  }
});

Limitations

  • Temperature reading: Both iOS and Android do not expose actual temperature values through their public APIs. The temperature field will always be null.
  • iOS: Thermal monitoring requires iOS 11 or later.
  • Android: Thermal monitoring requires Android 10 (API 29) or later.
  • Emulators: Thermal states may not work properly on emulators/simulators. Test on real devices.

Troubleshooting

iOS: Module not found

Make sure you've installed pods:

cd ios && pod install

Android: Build errors

Ensure your minSdkVersion in android/build.gradle is at least 21 (though thermal APIs require API 29).

No events received

  1. Make sure you're testing on a real device, not an emulator
  2. Verify thermal monitoring is available: await isThermalMonitoringAvailable()
  3. Check that you're calling addListener before the subscription

Contributing

License

MIT


Made with create-react-native-library