1. Recipes
  2. Building a Tray timer


Building a Tray timer

ToDesktop enables you to use the system's Tray in order to improve the experience of your desktop app users. The Tray is the area where applications can put their icons to be easily accessed by users. On macOS this is the menubar and on Windows it's the system tray.

Setting a tray title


Works on macOS only. Will throw on Windows & Linux

        import { tray } from '@todesktop/client-core';



Destroying a tray

This will destroy the tray item immediately

        import { tray } from '@todesktop/client-core';



Building a tray timer

Suppose we wanted to show users a 60 second timer in the tray

        import { tray } from '@todesktop/client-core';

function startTimer() {
  let remainingTime = 60;
  let timer = setInterval(() => {
    // Set the tray title to the remaining time
    window.tray.setTitle(`Remaining: ${remainingTime}`);

    remainingTime -= 1;
    if (remainingTime < 0) clearInterval(timer);
  }, 1000);


This will give you something like: