navigator.getBattery() returns a Promise that resolves to a BatteryManager (MDN) — charging state, level (0–1), time estimates, and events such as chargingchange and levelchange.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call navigator.getBattery. Start with this line.
JavaScript
navigator.getBattery()
Call
What it does
navigator.getBattery()
Primary signature.
navigator.getBattery(...)
Call with the arguments your case needs.
Built into the browser. Call getBattery(...) on a Navigator — no import required.
Library declarations
JavaScript
navigator.getBattery()
Parameters
Parameter
Description
Secure context
Required. HTTPS / localhost
Return Value
Return Value
Description
*
Promise<BatteryManager>
JavaScript Examples
Example 1 — Feature Detection
Check getBattery and secure context before calling.
Combine level + charging. Low only matters when not plugged in.
Return structured data. Easy to log or drive a soft UX mode.
Never break core features. Treat this as an optional hint only.
Compatibility
Browser Support
navigator.getBattery() implements the Battery Status API and is not Baseline. Available in many Chromium builds on secure contexts; removed from Firefox for privacy; Safari support is limited or absent. Always feature-detect and handle Promise rejection.
Google ChromeBattery Status · secure context (103+)
Limited
Microsoft EdgeFollow Chromium secure-context rules
Limited
Apple SafariLimited / often unavailable
Limited
OperaFollow Chromium Battery Status
Limited
Mozilla FirefoxAPI removed for privacy
Unavailable
Internet ExplorerNo Battery Status / getBattery
Unavailable
getBattery()Limited
Bottom line: Detect getBattery, use HTTPS, catch errors, and keep the app fully usable when battery data is unavailable.
Frequently Asked Questions
It returns a Promise that resolves to a BatteryManager with charging state, battery level (0–1), charging/discharging times, and events such as chargingchange and levelchange.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline), requires a secure context in modern Chromium, and may be missing for privacy reasons in some browsers (notably Firefox).
Yes in supporting Chromium browsers since Chrome 103: getBattery() is a secure-context feature (HTTPS or localhost). Calling it from an insecure context can throw SecurityError.
A number from 0.0 to 1.0 representing remaining charge — for example 0.75 means about 75%.
No. Desktops without a battery, privacy-restricted browsers, and a blocked Permissions-Policy: battery can omit or reject it. Always feature-detect and handle Promise rejection.
No. Battery status is for helpful UX (pause heavy work on low battery), not fingerprinting. Prefer privacy-respecting, optional enhancements.