notifications

Display notifications to the user, using the underlying operating system's notification mechanism. Because this API uses the operating system's notification mechanism, the details of how notifications appear and behave may differ according to the operating system and the user's settings.

On macOS, the notification looks something like this:

Example notification on macOS, located below the system clock, with a bold title reading "Click notification" followed by regular text reading "You clicked https://developer.mozilla.org/en-US/docs/MDN". The notification has the Firefox Nightly logo on the left side, and a link icon on the right.

On Windows, the notification persists in the Action Center until the browser is closed. The notification looks something like this:

Example notification on Windows 10, located above the system clock, with a bold title reading "Click notification" followed by regular text reading "You clicked https://developer.mozilla.org/en-US/docs/MDN". The notification has a small Firefox logo in the top left corner that is followed by "Mozilla Firefox", and a link icon to the left of the primary notification text.

To use this API, you need to have the "notifications" permission.

Types

notifications.NotificationOptions

Defines the content of a notification.

notifications.TemplateType

The type of notification. For example, this defines whether the notification can contain an image.

Functions

notifications.clear()

Clear a specific notification, given its ID.

notifications.create()

Create and display a new notification.

notifications.getAll()

Get all notifications.

notifications.update()

Update a notification.

Events

notifications.onButtonClicked

Fired when the user clicked a button in the notification.

notifications.onClicked

Fired when the user clicked the notification, but not on a button.

notifications.onClosed

Fired when a notification closed, either by the system or because the user dismissed it.

notifications.onShown

Fired immediately after a notification has been shown.

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
notifications
NotificationOptions
NotificationOptions.appIconMaskUrl
NotificationOptions.buttons
NotificationOptions.contextMessage
NotificationOptions.eventTime
NotificationOptions.imageUrl
NotificationOptions.isClickable
NotificationOptions.items
NotificationOptions.priority
NotificationOptions.progress
NotificationOptions.requireInteraction
TemplateType
clear
create
getAll
onButtonClicked
onClicked
onClosed
onClosed.byUser
onShown
update

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

Example extensions