react-native-battery-insight
v1.0.4
Published
A native module to fetch battery details for React Native
Maintainers
Readme
react-native-battery-insight 🔋
A lightweight, comprehensive native module to fetch detailed battery diagnostics for React Native applications.
Get access to advanced metrics like voltage, temperature, health, and current usage (µA) directly from the native BatteryManager service.
✨ Features
⚡ Detailed Diagnostics
Go beyond simple battery level—fetch voltage, temperature, health, and technology.🔌 Live Charging Info
Detect whether the device is plugged into AC, USB, Wireless, or Dock.🩺 Health Monitoring
Identify battery health states like Good, Overheat, Dead, Over Voltage.📉 Power Saving Detection
Check whether Battery Saver / Low Power Mode is enabled.🤖 Cross-Platform API
Unified API for Android & iOS with safe fallbacks for iOS limitations.📦 Zero Dependencies
Pure native implementation—no external libraries.
📦 Installation
npm install react-native-battery-insight📦 Sample Code
import { getBatteryState } from 'react-native-battery-insight';
const checkBattery = async () => {
const data = await getBatteryState();
console.log(`Level: ${(data.level * 100).toFixed(0)}%`);
console.log(`Status: ${data.status}`);
if (data.isCharging) {
console.log(`Plugged in via: ${data.plugged}`);
}
// Advanced Diagnostics (Android only)
if (data.voltage > 0) {
console.log(`Voltage: ${data.voltage} mV`);
console.log(`Temperature: ${data.temperature / 10} °C`);
}
};| Data Point | Description | Android | iOS | |----------------------|-----------------------------------------------|:-------:|:---:| | Level | Battery percentage (0.0 – 1.0) | ✅ | ✅ | | Status | Charging / Discharging / Full | ✅ | ✅ | | isCharging | Boolean charging state | ✅ | ✅ | | Low Power Mode | Battery Saver / Low Power Mode | ✅ | ✅ | | Plugged Source | AC / USB / Wireless / Dock | ✅ | ❌ | | Health | Good / Overheat / Dead | ✅ | ❌ | | Temperature | Tenths of °C | ✅ | ❌ | | Voltage | Millivolts (mV) | ✅ | ❌ | | Technology | Battery chemistry | ✅ | ❌ | | Current (Now) | Instantaneous current (µA) | ✅ | ❌ | | Current (Avg) | Average current (µA) | ✅ | ❌ | | Charge Counter | Battery capacity (µAh) | ✅ | ❌ | | Energy Counter | Remaining energy (nWh) | ✅ | ❌ | | Time Remaining | Estimated time to full charge (ms) | ✅ | ❌ |
