navigator.clearAppBadge() clears a badge on the current app’s icon by setting it to nothing (MDN). It is part of the Badging API and returns a Promise that resolves with undefined.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call navigator.clearAppBadge. Start with this line.
JavaScript
navigator.clearAppBadge()
Call
What it does
navigator.clearAppBadge()
Primary signature.
navigator.clearAppBadge(...)
Call with the arguments your case needs.
Built into the browser. Call clearAppBadge(...) on a Navigator — no import required.
Library declarations
JavaScript
navigator.clearAppBadge()
Parameters
Parameter
Description
Secure context
Required. HTTPS / localhost
Return Value
Return Value
Description
*
Promise → undefined
JavaScript Examples
Example 1 — Feature Detection
Check clearAppBadge, setAppBadge, and secure context together.
Badging API not supported
(or "Badge cleared (unread = 0)" when supported)
How It Works
Detect both APIs. You need set for counts and clear for zero.
Branch on unread. Positive → setAppBadge(n); zero → clearAppBadge().
Await the Promise. Badging is async — wait before reporting status.
Catch errors. Return a soft message so UI flow does not crash.
Example 4 — clearAppBadge() vs setAppBadge(0)
Both clear the badge; pick the clearer intent for your code.
JavaScript
async function compareClearStyles() {
if (!navigator.clearAppBadge || !navigator.setAppBadge) {
return "Badging API not supported";
}
await navigator.clearAppBadge();
await navigator.setAppBadge(0);
return "Both clearAppBadge() and setAppBadge(0) clear the badge";
}
compareClearStyles().then(console.log);
Early exits. Unsupported or insecure → structured { ok: false }.
Try / catch. Turns DOMExceptions into a reason string.
Success shape.{ ok: true, reason: "cleared" } is easy to log.
UI stays calm. Callers can ignore soft failures without crashing.
Compatibility
Browser Support
navigator.clearAppBadge() is part of the Badging API and is not Baseline. Chromium (Chrome / Edge ~81+) on Windows & macOS for installed PWAs; Safari on iOS / iPadOS 16.4+ for home-screen web apps; Firefox and desktop Safari generally lack support. Always feature-detect and use HTTPS.
✓ Limited availability · Not Baseline
Navigator.clearAppBadge()
Promise-based clear — sets the app icon badge to nothing.
LimitedNot Baseline
Google ChromeBadging ~81+ · installed PWA (Win/macOS)
Limited
Microsoft EdgeBadging ~81+ · installed PWA (Win/macOS)
Limited
Apple SafariiOS/iPadOS 16.4+ home-screen; desktop Safari: no
Limited
OperaFollow Chromium Badging where available
Limited
Mozilla FirefoxNo Badging API support
Unavailable
Internet ExplorerNo Badging / clearAppBadge support
Unavailable
clearAppBadge()Limited
Bottom line: Detect clearAppBadge, clear when unread hits zero, handle Promise errors, and keep in-app unread UI as the source of truth.
Frequently Asked Questions
It clears a badge on the current app’s icon by setting it to nothing — removing the numeric or flag indicator from an installed PWA / home-screen icon.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) and requires a secure context. Always feature-detect.
Yes. The Badging API is a secure-context feature (HTTPS or localhost) in supporting browsers.
A Promise that resolves with undefined when the call succeeds. Handle rejections for InvalidStateError, SecurityError, or NotAllowedError.
Both clear the badge. clearAppBadge() is the dedicated clear method. Passing 0 to setAppBadge() also sets the badge to nothing. Prefer clearAppBadge() when your intent is simply “remove the badge.”
Commonly after the user has read all messages or cleared pending items — MDN’s example: once all messages are read, call clearAppBadge() to remove the notification badge.