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!
Asked
Active
Viewed 3,516 times
6

Quantalabs
- 379
- 2
- 14
-
2`win.maximize()` ? – snwflk Oct 03 '20 at 21:26
1 Answers
15
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);

Rhayene
- 805
- 9
- 20