navigator.setAppBadge(contents?) sets a badge on the icon associated with this app (Badging API). Pass a number for a count, omit it for a platform flag (dot), or pass 0 to clear.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call navigator.setAppBadge. Start with this line.
JavaScript
navigator.setAppBadge(contents?)
Call
What it does
navigator.setAppBadge(contents?)
Primary signature.
navigator.setAppBadge(...)
Call with the arguments your case needs.
Built into the browser. Call setAppBadge(...) on a Navigator — no import required.
Library declarations
JavaScript
navigator.setAppBadge(contents?)
Parameters
Parameter
Description
contents
Optional. Number for the badge; omit → flag; 0 → clear
Secure context
Required. HTTPS / localhost
Return Value
Return Value
Description
*
Promise → undefined
JavaScript Examples
Example 1 — Set an Unread Count
Pass a number so the icon can show how many items are pending (MDN).
Sync with UI. Clear when your in-app unread count hits zero.
Compatibility
Browser Support
Navigator.setAppBadge() is part of the Badging API. MDN marks it Limited availability (not Baseline). Requires a secure context.
✓ Limited availability
Navigator.setAppBadge()
Best support in Chromium-based browsers for installed PWAs. Missing or partial on Firefox and some platforms — always feature-detect.
LimitedNot Baseline
Google ChromePWA / modern (secure)
Yes
Microsoft EdgePWA / modern (secure)
Yes
OperaPWA / modern (secure)
Yes
Apple SafariPartial / platform-dependent
Partial
Mozilla FirefoxNot supported
No
Internet ExplorerNot supported
No
setAppBadge()Feature-detect required
Bottom line: Ship badging only after detecting the method and handling Promise errors. See the MDN setAppBadge() reference.
Frequently Asked Questions
It sets a badge on the icon associated with the app. Pass a number to show that count, omit the argument for a platform flag/dot, or pass 0 to clear the badge (set it to nothing).
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) and requires a secure context.
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 set. Handle rejections for InvalidStateError, SecurityError, or NotAllowedError.
Call navigator.clearAppBadge(), or navigator.setAppBadge(0). Prefer clearAppBadge() when your only intent is to remove the badge.
Often no. App badges usually appear on installed PWA / dock / home-screen icons. Desktop demos may resolve without a visible badge — that is expected.