Skip to main content
System tray icons let your application remain available without requiring a visible window while the application is alive. They are commonly used for messaging apps, clipboard managers, music players, background services, and utilities. Hide the last window instead of allowing its OS close request if you want the tray application to remain alive. Create tray icons through app.createTrayIcon(), which registers them with the owning application. You do not need to wait for app.whenReady() first.

Before you begin

Tray icons can be created before or after the application becomes ready. The following pattern creates one after readiness because it keeps all setup in one place:

Creating your first tray icon

The example below creates a tray icon with two menu items.
After launching, your application will appear in the operating system’s notification area with a context menu.

Showing and hiding the window

Many tray applications hide instead of closing.
This produces the familiar behavior used by applications like Discord, Slack, and Spotify.

Updating the tray icon

You can replace the icon at runtime.
Or provide raw RGBA pixels. Pass width and height, or pass width alone for a square icon.
This is useful for:
  • unread notifications
  • connection status
  • syncing indicators
  • recording state

Updating the tooltip

Changing the tooltip is an easy way to communicate application state without opening a window.

Replacing the menu

On Windows and macOS, you can replace the context menu after creation. On Linux, the tray backend keeps the first menu object and this API cannot replace it, so configure the initial menu before creating the tray icon. The following call replaces the menu on Windows and macOS:
On Windows and macOS, this allows the menu to reflect the application’s current state. On Linux, configure the menu when you create the tray icon because later calls do not replace the initial native menu.

Responding to clicks

On platforms that support tray pointer events, tray icons emit click, double-click, enter, move, and leave events.
Linux tray backends do not emit these pointer events. Use the tray context menu or an application-window interaction there. Menu selections are handled separately through the application’s custom-menu-click event.

Temporarily hiding the tray icon

Hide the icon without destroying it.
All menu items and event listeners remain intact.

Removing the tray icon

To remove the icon permanently:
Calling app.exit() automatically disposes every tray icon owned by the application.

Platform differences

Some tray features are platform specific.

Next steps

The guide covers the most common workflows. For the complete API, available methods, events, and configuration options, see the TrayIcon API Reference.