PWA Demos
Battery Status

Battery API Demo

Get real-time battery information from the user's device in your web apps with a few lines of JavaScript.

Battery Status Logo

Interactive Demo

1. Install the app on your device, and launch it from your homescreen. Or skip this step, and try it from your current browser.

2. Get data about the battery status of the device by clicking on one of the buttons below.

3. Plug and unplug your device to see the values above change in real time.

4. Check out the code of the demo below to implement the Battery API in your PWA.

What's the Battery Status API?

The Battery Status API provides web apps with real-time insights into a device's power source, battery level, and estimated charge or discharge time. It emits events when this data changes, helping apps optimize performance by reducing energy-intensive tasks when battery levels are low.

Use cases for the Battery Status API

The Battery Status API is particularly useful for web applications that need to optimize energy consumption and enhance user experience based on the device's battery state.

  • Media streaming apps can reduce video quality or pause background downloads when battery levels are low.
  • Gaming or interactive applications can adjust graphics settings or disable non-essential animations to conserve power.
  • Productivity tools can defer intensive background tasks, like data syncing or large computations, until the device is charging.

By leveraging this API, developers can create applications that are more responsive to the user's device conditions, improving both performance and battery life.

Code

Links & Documentation

Your app here

Unlock the powers of the web today

Try our PWA toolkit free of charge and without limits for 14 days. No credit card required.

Get started See plans