Skip to main content
Desktop notifications are a simple way to inform users about events while your application is running in the background. WebviewJS provides a browser-compatible Notification API, so if you’ve previously used the Web Notifications API, the same patterns work here without requiring a browser or service worker.

Creating your first notification

The simplest notification only needs a title.
Most applications also include a message body.
Unlike browser notifications, there is no show() method. The notification is displayed immediately when constructed.

Displaying an icon

You can provide either a platform icon name or a path to an image.
On Linux, you may also use freedesktop icon names.

Displaying an image

Notifications can include a larger preview image.
Passing a Buffer is useful when the image was downloaded or generated entirely in memory.

Responding to notification events

Notifications are EventEmitters.
You can also use browser-style event handlers.

Action buttons

Long-running applications often provide quick actions directly inside notifications.
Action buttons require persistent: true. Attempting to use actions without persistence throws a TypeError.

Persistent notifications

By default, notifications are fire-and-forget. If the rest of your application exits immediately afterwards, the notification will no longer receive interaction events. Enable persistence when the user needs to interact with the notification.
Persistent notifications keep the Node.js process alive until the notification is dismissed or interacted with.

Closing a notification

On supported platforms you can close a notification yourself.
On platforms that do not expose programmatic closing, the notification remains visible until the user dismisses it or it naturally expires.

Permissions

Unlike browsers, desktop applications do not ask for notification permission.
Likewise,
always resolves to "granted" for browser compatibility.

Platform differences

Some notification features vary by platform.

Next steps

This guide covers the most common notification workflows. For the complete constructor, every available option, supported events, and platform-specific behavior, see the Notification API Reference.