navigator.clearAppBadge() is part of the Badging API. Learn how to remove an app icon badge after unread items are handled, pair it with setAppBadge(), use secure contexts, and try five beginner examples.
01
Kind
Method
02
Returns
Promise<undefined>
03
Status
Limited availability
04
Context
Secure (HTTPS)
05
API family
Badging API
06
Pairs with
setAppBadge()
Fundamentals
Introduction
Installed Progressive Web Apps can show a small badge on their icon — a number like 3 for unread messages, or a simple flag/dot. That badge is set with navigator.setAppBadge().
When nothing is left to highlight (inbox empty, tasks done), call navigator.clearAppBadge() to remove it. The badge value becomes nothing, and the icon returns to a clean state.
💡
Installed apps first
Badging is most useful for PWAs / home-screen apps. In a normal browser tab the methods may exist but have no visible icon to badge — always feature-detect and treat badging as progressive enhancement.
Concept
Understanding the clearAppBadge() Method
clearAppBadge() is the dedicated “remove badge” call in the Badging API.
No parameters — just call navigator.clearAppBadge().
Sets badge to nothing — no number / flag on the icon.
Returns a Promise — resolves with undefined on success.
Secure context — HTTPS / localhost required.
May reject — e.g. document not fully active, same-origin issues, or permission not granted (NotAllowedError).
Alternative — setAppBadge(0) also clears the badge.
Foundation
📝 Syntax
General form of the method:
JavaScript
navigator.clearAppBadge()
Parameters
None.
Return value
A Promise that resolves with undefined.
Common patterns
JavaScript
// MDN: clear after messages are read
navigator.clearAppBadge();
// Safer async pattern with feature detect
async function clearBadgeSafe() {
if (!navigator.clearAppBadge) {
return "Badging API not supported";
}
try {
await navigator.clearAppBadge();
return "Badge cleared";
} catch (err) {
return "clearAppBadge error: " + err.name;
}
}
// Pair with setAppBadge for unread counts
async function syncUnreadBadge(unread) {
if (!navigator.setAppBadge || !navigator.clearAppBadge) return;
if (unread > 0) {
await navigator.setAppBadge(unread);
} else {
await navigator.clearAppBadge();
}
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Feature detect
typeof navigator.clearAppBadge === "function"
Clear the badge
await navigator.clearAppBadge()
Set a count
await navigator.setAppBadge(n)
Clear via set
await navigator.setAppBadge(0)
Secure context?
window.isSecureContext
Snapshot
🔍 At a Glance
Four facts to remember about navigator.clearAppBadge().
Returns
Promise
Resolves undefined
Availability
Limited
Not Baseline
Context
HTTPS
Secure required
Effect
nothing
Badge cleared
Compare
📋 clearAppBadge() vs setAppBadge()
clearAppBadge()
setAppBadge()
Purpose
Remove the badge
Show a number or flag
Parameters
None
Optional contents number
Badge result
nothing (cleared)
Number, flag (no arg), or nothing if 0
Return type
Promise<undefined>
Promise<undefined>
Typical use
Inbox empty / all read
Unread count > 0
Hands-On
Examples Gallery
Examples follow MDN Badging API patterns. Prefer Try It Yourself — a visible badge usually needs an installed PWA / home-screen app on a supporting OS.
📚 Getting Started
Detect the Badging API and clear a badge the MDN way.
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
Call this helper whenever your unread count changes so the icon stays honest.
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";
}
// Dedicated clear
await navigator.clearAppBadge();
// Equivalent clear via set
await navigator.setAppBadge(0);
return "Both clearAppBadge() and setAppBadge(0) clear the badge";
}
compareClearStyles().then(console.log);
navigator.clearAppBadge() belongs to the Badging API and is not Baseline. Support is strongest for installed PWAs on Chromium platforms and Safari (home screen / macOS Sonoma+). Firefox generally lacks support. Always feature-detect, use HTTPS, and treat badges as progressive enhancement.
✓ Limited availability · Not Baseline
Navigator.clearAppBadge()
Promise that clears the app icon badge (sets badge to nothing).
LimitedNot Baseline
Google ChromeBadging for installed apps (OS-dependent)
Limited
Microsoft EdgeFollow Chromium Badging support
Limited
Apple SafariHome screen / installed web apps (version-dependent)
Limited
OperaOften follows Chromium where Badging exists
Limited
Mozilla FirefoxTypically unavailable — feature-detect
Unavailable
Internet ExplorerNo Badging / clearAppBadge support
Unavailable
clearAppBadge()Limited
Bottom line: Detect clearAppBadge, clear when unread is zero, handle Promise rejections, and never rely on badges for critical information.
Wrap Up
Conclusion
navigator.clearAppBadge() removes the app icon badge when there is nothing left to highlight. Detect support, clear after unread counts hit zero, handle Promise errors, and keep in-app indicators as the source of truth.
It clears a badge on the current app's icon by setting the badge to nothing — removing the numeric or flag indicator from the installed PWA / home-screen icon.
No. MDN/BCD mark it as standard-track and not Experimental or Deprecated. It is Limited availability (not Baseline), so always feature-detect. No Deprecated / Experimental / Non-standard status banner is required.
Yes. The Badging API is a secure-context feature (HTTPS or localhost) in supporting browsers.
A Promise that resolves with undefined when the badge is cleared (or when the call succeeds).
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.
Did you know?
Calling navigator.setAppBadge() with no argument usually shows a flag/dot (not a number). Calling setAppBadge(0) or clearAppBadge() removes that indicator entirely.