Skip to content

UseGetBattery

katanakit-js / useGetBattery

function useGetBattery(): Promise<BatteryManager | null>;

Defined in: infrastructure/sensors/sensors.service.ts:315

Gets the device battery status.

Promise<BatteryManager | null>

A BatteryManager object or null if the API is unavailable.

const battery = await useGetBattery();
if (battery) {
console.log(`${Math.round(battery.level * 100)}%`);
}