How to restore window size


Hi there. I’m super new to Electron and haven’t been able to find a way to restore the window size each time my app launches. I’ve tried various solutions I’ve found on the interwebs, but I haven’t gotten any to work. Maybe someone could explain how to do it in dumb-speak so that I could understand it?

Here’s the repository:

Any help would be greatly appreciated!



Have a look at the usage for electron-window-state package:

const windowStateKeeper = require('electron-window-state');
let win;

app.on('ready', function () {
  // Load the previous state with fallback to defaults
  let mainWindowState = windowStateKeeper({
    defaultWidth: 1000,
    defaultHeight: 800

  // Create the window using the state information
  win = new BrowserWindow({
    'x': mainWindowState.x,
    'y': mainWindowState.y,
    'width': mainWindowState.width,
    'height': mainWindowState.height

  // Let us register listeners on the window, so we can update the state
  // automatically (the listeners will be removed when the window is closed)
  // and restore the maximized or full screen state

That is added in main.js where you initialize your BrowserWindow


Thanks! It took a little trial and error, but that worked perfectly (once I finally figured out how to get it to work).