This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The setAppBadge() method of the Navigator interface sets a badge on the icon associated with this app. If a value is passed to the method, this will be set as the value of the badge. Otherwise the badge will display as a dot, or other indicator as defined by the platform.
setAppBadge() setAppBadge(contents)
contents OptionalA number which will be used as the value of the badge. If contents is 0 then the badge will be set to nothing, indicating a cleared badge.
A Promise that resolves with undefined.
InvalidStateError DOMException
Thrown if the document is not fully active.
SecurityError DOMException
Thrown if the call was blocked by the same-origin policy.
NotAllowedError DOMException
Thrown if PermissionStatus.state is not granted.
In the example below an unread count is passed to setAppBadge(). The badge should then display 30.
const unread = 30; navigator.setAppBadge(unread);
| Specification |
|---|
| Badging API> # setappbadge-method> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
setAppBadge |
81["Windows and macOS since Chrome 81.", "ChromeOS since Chrome 91.", "Linux offers no universal badging API on the operating system level."] |
81["Windows and macOS since Edge 81.", "ChromeOS since Edge 91.", "Linux offers no universal badging API on the operating system level."] |
No | No | 17["Badging is supported for installed web apps on macOS Sonoma and higher.", "Passing0 as an argument will clear the badge instead of displaying an unnumbered dot."] |
No | No | No | 16.4["Badging is supported for web apps saved to the home screen.", "Passing0 as an argument will clear the badge instead of displaying an unnumbered dot."] |
No | No | NoBadging is supported for web apps saved to the home screen. |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/setAppBadge