Content
useBattery
A custom hook to retrieve battery information and status.
useBattery
Usage
API
useBattery
Returns
Name | Type | Description |
---|---|---|
batteryState | BatteryState | An object with battery state properties. |
batteryState.supported | boolean | Indicates if the Battery API is supported. |
batteryState.loading | boolean | True while fetching initial battery data. |
batteryState.level | number | null | Battery level as a decimal (0.0 to 1.0), or null if unavailable. |
batteryState.charging | boolean | null | Whether the battery is currently charging, or null if unavailable. |
batteryState.chargingTime | number | null | Estimated time in seconds until fully charged, or null if unavailable. |