Skip to main content

useBatteryStatus()

The useBatteryStatus() hook provides real-time information about the device's battery level and charging status, automatically updating as these values change.

Import

import { useBatteryStatus } from 'react-haiku';

Usage

Loading...

import { useBatteryStatus } from 'react-haiku';

export const Component = () => {
const {level, isCharging} = useBatteryStatus();

return (
<div>
<p>Battery Level: {level}</p>
<p>Is Battery Charging: {isCharging ? "True" : "False"}</p>
</div>
);
}