someone324443
someone324443

Reputation: 43

How to hide electron app on startup in tray

I have a electron app with a 'hide to tray' function like in this answer "https://stackoverflow.com/a/38980563/16312733".

But I want that the application doesn't open/show the main windows on startup.

I saw that here is already a question about that "Auto launch to system tray on system startup - Electron + Ionic app" but this question is already a year old and I think this question doesnt get a answer any time soon.

So is there a way to hide the main window on startup so the software is only visible in the tray?

Upvotes: 2

Views: 3010

Answers (1)

turbopasi
turbopasi

Reputation: 3605

When your app is about to create its main windows (BrowserWindow) you can use the option show to keep the window hidden after creation.

const mainWindow = new BrowserWindow({ show: false });
// Window will be created but stays hidden

After that you can just show it manually whenever you are ready

mainWindow.show();

Read here in the official docs .

Upvotes: 3

Related Questions