CautionThis API is deprecated in several browsers (including Firefox) due to privacy and fingerprinting concerns. Its availability may vary across different environments.
ImportantAccess to battery information is only allowed in Secure Contexts (HTTPS).
The useBatteryStatus hook with the native Web Battery Status API to retrieve live telemetry from the device's battery. It monitors charging status, current energy levels, and provides estimates for full charge or discharge times.
This hook is ideal for building progressive web apps (PWAs) that need to adjust behavior based on energy availability—such as pausing background synchronization, reducing animation complexity, or warning users before critical battery thresholds are met.
| Name | Type | Description |
|---|---|---|
| isSupported | boolean | Indicates if the browser supports the Battery Status API. |
| battery.level | number | null | Value from 0.0 to 1.0 representing the charge level. |
| battery.charging | boolean | null | True if the device is currently plugged in. |
| battery.chargingTime | number | null | Seconds until full charge (0 if full, Infinity if unknown). |
| battery.dischargingTime | number | null | Seconds until empty (Infinity if charging or unknown). |