files/en-us/web/api/navigator/setappbadge/index.md
{{APIRef("Badging API")}}{{securecontext_header}}
The setAppBadge() method of the {{domxref("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 {{optional_inline}}
contents is 0 then the badge will be set to nothing, indicating a cleared badge.A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}}.
InvalidStateError {{domxref("DOMException")}}
SecurityError {{domxref("DOMException")}}
NotAllowedError {{domxref("DOMException")}}
granted.In the example below an unread count is passed to setAppBadge(). The badge should then display 30.
const unread = 30;
navigator.setAppBadge(unread);
{{Specifications}}
{{Compat}}