Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 845
Quantalabs Avatar asked Feb 19 '26 20:02

Quantalabs


1 Answers

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);
like image 131
Rhayene Avatar answered Feb 21 '26 13:02

Rhayene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!