Quantalabs
Quantalabs

Reputation: 449

Electron: Maximize Window on Start

I'm creating a electron app and am trying to allow it to open so that it is maximized on start. Is there a function of some kind that you put in the main.js to maximize the window? Thanks!

Upvotes: 11

Views: 6851

Answers (1)

Rhayene
Rhayene

Reputation: 945

win.maximize() will maximize your window.

One caveat: even if you instantly call this function after creating the BrowserWindow you may still see the small window before maximizing. So hiding the window and showing it only after maximizing should do the trick.

const { BrowserWindow, app } = require("electron");

let win;
app
  .whenReady()
  .then(() => {
    win = new BrowserWindow({
      show: false,
    });
    win.maximize();
    win.show();
  })
  .catch(console.error);

Upvotes: 26

Related Questions