Battery Status API
Monitor device battery level, charging status, and power management with the Battery Status API. Optimize your web app based on device power conditions.
Battery Status
This example shows your current battery level and charging status, giving you a complete overview of your device's power situation at a glance.
Output
Click Run to see output...
Charging Change
This example detects when you connect or disconnect your device from a power source, updating you immediately when your charging status changes.
Output
Click Run to see output...
Level Change
This example monitors your battery level in real-time, showing you exactly how quickly your battery is charging or discharging as you use your device.
Output
Click Run to see output...
Time Remaining
This example shows you how much time is left until your battery is fully charged when plugged in, helping you plan when you'll have a full battery.
Output
Click Run to see output...
All Events
This example combines all battery information in one place, tracking charging status, battery level, and time estimates simultaneously for complete monitoring.
Output
Click Run to see output...