A React Native Module for monitoring battery status, power mode, and thermal conditions on both iOS and Android.
compatible with both New (Fabric) and Old Architecture.
- Get real-time battery level
- Check battery charging state
- Detect low power mode activation
- Monitor device thermal conditions
- Listen for battery state and level changes
| Architecture | Version Range |
|---|---|
| New Architecture (Fabric) | >=2.0.0 (Latest) |
| Old Architecture | >=1.0.0 <2.0.0 |
Retrieves the current battery level as a percentage (0-100).
import BatteryModule from 'react-native-battery-check';
BatteryModule.getBatteryLevel().then((level) => {
console.log(`Battery Level: ${level}%`);
});Returns the battery charging state.
ChargingUnpluggedFullUnknown
BatteryModule.getBatteryState().then((state) => {
console.log(`Battery State: ${state}`);
});Checks if Low Power Mode is enabled.
BatteryModule.isLowPowerModeEnabled().then((isEnabled) => {
console.log(`Low Power Mode: ${isEnabled ? 'Enabled' : 'Disabled'}`);
});Returns the current thermal state of the device.
NominalFairSeriousCriticalUnknown
BatteryModule.getThermalState().then((state) => {
console.log(`Thermal State: ${state}`);
});Starts listening to battery-related events.
onBatteryLevelChangeonBatteryStateChange
BatteryModule.startListenerWithEvent('onBatteryLevelChange');Stops listening to the specified event.
BatteryModule.stopListenerWithEvent('onBatteryLevelChange');A complete usage example can be found in the example folder of this repository.
import BatteryModule from 'react-native-battery-check';
const checkBattery = () => {
BatteryModule.getBatteryLevel().then((level) => {
BatteryModule.getBatteryState().then((state) => {
console.log(`Battery: ${level}% - State: ${state}`);
});
});
};
BatteryModule.startListenerWithEvent('onBatteryLevelChange');
// Cleanup on unmount
return () => BatteryModule.stopListenerWithEvent('onBatteryLevelChange');- React Native New & Old Architecture (TurboModule Compatible)
- iOS & Android support
MIT