useBatteryStatus()
The
useBatteryStatus() hook provides real-time information about the device's battery level and charging status.Import
typescript
Usage
Loading battery status...
Component.tsx
API
This hook does not accept any arguments.
Returns an object with the following properties:
supported– boolean true if the Battery Status API is supported.loading– boolean true while fetching the initial battery status.level– number | null battery level value between 0.0 and 1.0.percentage– number | null battery level percentage (0-100).charging– boolean | null true if the battery is currently charging.chargingTime– number | null remaining time in seconds until fully charged.dischargingTime– number | null remaining time in seconds until discharged.