navigator.setAppBadge() sets a badge on your installed app icon — for example an unread count. Learn numeric badges, flag badges, clearing with 0 / clearAppBadge(), five examples, and try-it labs.
01
Kind
Method
02
Returns
Promise<undefined>
03
Status
Limited (not Baseline)
04
Context
Secure (HTTPS)
05
API family
Badging API
06
Pair with
clearAppBadge()
Fundamentals
Introduction
Chat and mail apps show a small number on the home-screen icon when messages are unread. On the web, the Badging API lets an installed PWA do the same.
Call navigator.setAppBadge(contents) to set a count, or navigator.setAppBadge() with no argument for a simple “something is new” indicator (dot / flag, depending on the OS).
💡
No Dep / Exp / Non-standard banner
MDN marks Limited availability and a secure context, but not Deprecated, Experimental, or Non-standard. Always feature-detect and pair with clearAppBadge().
Concept
Understanding the setAppBadge() Method
Optional number — contents becomes the badge value.
No argument — platform shows a flag/dot-style badge.
0 clears — sets the badge to nothing (same idea as clear).
Promise — resolves with undefined on success.
Secure context — HTTPS / localhost.
Best on installed apps — dock / home-screen icons, not ordinary tabs.
contents (optional) — a number used as the badge value. If 0, the badge is cleared.
Return value
A Promise that fulfills with undefined.
Common exceptions / rejections
InvalidStateError — document not fully active.
SecurityError — blocked by same-origin policy in some cases.
NotAllowedError — permission not granted.
MDN-style unread count
JavaScript
const unread = 30;
navigator.setAppBadge(unread);
Cheat Sheet
⚡ Quick Reference
Goal
Code
Feature detect
typeof navigator.setAppBadge === "function"
Show count
await navigator.setAppBadge(5)
Show flag / dot
await navigator.setAppBadge()
Clear via set
await navigator.setAppBadge(0)
Clear via clear
await navigator.clearAppBadge()
Secure context?
window.isSecureContext
Snapshot
🔍 At a Glance
Four facts to remember about navigator.setAppBadge().
Returns
Promise
undefined
Status
Limited
Not Baseline
Context
HTTPS
Secure required
Arg 0
clears
Badge nothing
Compare
📋 setAppBadge vs clearAppBadge
setAppBadge
clearAppBadge
Purpose
Set count or flag
Remove badge
Clearing
setAppBadge(0) also clears
Dedicated clear call
Typical use
Unread rose to 12
User read everything
Beginner habit
Update when count changes
Clear when count hits 0
Hands-On
Examples Gallery
Examples feature-detect first. On an ordinary browser tab you may get a resolved Promise with no visible badge — install as a PWA on a supporting OS to see the icon update.
📚 Getting Started
Detect Badging support and set a numeric badge.
Example 1 — Feature Detection
Check setAppBadge, clearAppBadge, and secure context together.
navigator.setAppBadge() belongs to the Badging API and is not Baseline. Support is strongest for installed PWAs on some Chromium-based platforms. Always feature-detect, use HTTPS, and keep an in-app unread UI as fallback.
✓ Limited · Not Baseline
Navigator.setAppBadge()
Promise → set a numeric or flag badge on the app icon.
LimitedNot Baseline
Google ChromeBadging for installed PWAs where supported
Limited
Microsoft EdgeFollow Chromium Badging support
Limited
OperaFollow Chromium where available
Limited
Mozilla FirefoxTypically unavailable — feature-detect
Unavailable
Apple SafariCheck current PWA badging support
Limited
Internet ExplorerNo Badging API
Unavailable
setAppBadge()Limited
Bottom line: Detect the method, set counts on HTTPS for installed apps, clear with clearAppBadge() or setAppBadge(0), and never rely on a visible badge in every browser tab.
Wrap Up
Conclusion
navigator.setAppBadge() is the Badging API way to put an unread count or flag on your installed app icon. Feature-detect it, call it on HTTPS, and clear with clearAppBadge() when the user is caught up.
Limited Badging API — set counts or flags on installed app icons.
5
Core concepts
🔔01
Sets
app icon badge
PWA
📊02
Support
Limited
Not Baseline
🔢03
Number
shows count
contents
⚫04
No args
flag / dot
Platform
❌05
Zero
clears badge
or clearAppBadge
❓ Frequently Asked Questions
It sets a badge on the app icon associated with the current site/PWA. Pass a number to show that count, omit the argument for a platform-defined flag/dot, or pass 0 to clear the badge.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) and requires a secure context. No 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 set successfully.
Call navigator.clearAppBadge(), or navigator.setAppBadge(0). Prefer clearAppBadge() when your only intent is to remove the badge.
Often no. Badges usually appear on installed PWA / dock / home-screen icons. Desktop demos may resolve without a visible badge — that is expected for beginners.
Did you know?
Some platforms only show badges for apps the user installed to the home screen or dock. Your Promise can still resolve while a normal browser tab shows nothing — test with a real install when verifying UX.