The Badging API puts a number, or a dot, on your installed app's icon: in the Windows taskbar, the macOS Dock, the ChromeOS shelf, and the iPhone and iPad Home Screen.
// From a page or the service worker
if ('setAppBadge' in navigator) {
navigator.setAppBadge(3); // show 3
navigator.setAppBadge(); // show a dot (no number)
navigator.clearAppBadge(); // remove it
}
Where it works
- Chrome and Edge on Windows, macOS and ChromeOS, for installed apps.
- Safari on iOS and iPadOS 16.4+ for Home Screen web apps, and on macOS for web apps in the Dock. On Apple platforms the app needs notification permission for badges to show.
- Not on Android: Android shows notification dots from your notifications instead.
From a push message
The most useful pattern is updating the badge when a push arrives, so it is right even when the app is closed:
self.addEventListener('push', (event) => {
const data = event.data.json();
event.waitUntil(Promise.all([
self.registration.showNotification(data.title, { body: data.body }),
navigator.setAppBadge?.(data.unread),
]));
});
Clear it when the user opens the relevant screen. Keep the number meaningful: unread messages or tasks that need action, not marketing.
Browser support
| Feature | Chrome / Edge desktop | Chrome Android | Safari iOS / iPadOS | Safari macOS | Firefox desktop | Firefox Android | Samsung Internet |
|---|---|---|---|---|---|---|---|
| App badge (Badging API) | Chrome / Edge desktop: Yes (Installed apps) | Chrome Android: No | Safari iOS / iPadOS: Partial (Home Screen apps with notification permission) | Safari macOS: Partial (Web apps in the Dock) | Firefox desktop: No | Firefox Android: No | Samsung Internet: No |