Web APIs

Badging API

Checking compatibility...

Display a badge on your app icon to indicate status or notifications. Learn how to set and clear badges programmatically.

Install App

This example shows how to prompt users to install your web app as a PWA, which is required before you can use badges on your app icon.

=
=
=
=
=
=

Output

Click Run to see output...

Set Badge

This example adds a notification badge with a random number to your app icon, similar to how messaging apps show unread message counts.

=
=
=
=
=
=

Output

Click Run to see output...

Clear Badge

This example removes the notification badge from your app icon, typically used when a user has viewed all notifications or messages.

=
=
=
=
=
=

Output

Click Run to see output...