# Battery API 🔋

aka Battery Status API

📗

The Battery Status API, more often referred to as the Battery API, provides information about the system's battery charge level and lets you be notified by events that are sent when the battery level or charging status change.
This can be used to save changes before the battery runs out in order to prevent data loss.

🛑

This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes.


# Examples

# Demo #1

Battery demo with listeners

Battery Status:

  • level:
  • charging:
  • chargingTime:
  • dischargingTime:
Code
navigator.getBattery()
  .then((battery) => {
    console.log(battery)
    // => Battery Manager Obj
    // => level, charging, chargingTime, dischargingTime, etc
  })
1
2
3
4
5
6