This post will cover how to fix the electron white screen app startup. If you start the electron tutorial app you can see it flashes white and then loads the css setting the correct color. The electron API currently allows two ways of fixing this.
This is what the the tutorial app looks like when it starts before applying this fix.
One way is to let the app flash before load, but setting the white color to something else. In this case it would be #312450. This is a setting on the BrowserWindow and in our tutorial app we set it on line 13 in main.js.
If this works well with your app this is a good alternative because it will appear to load your app faster than the other one we will look at now. If your app has more than one background color, like the tutorial app does (the menu background and the main container background), setting the startup background color is not enough. But this is a matter of taste, there is no right or wrong. This is what the official docs say:
"Note that even for apps that use ready-to-show event, it is still recommended to set backgroundColor to make app feel more native."
This technique waits for the event ready-to-show to fire. When that happens we take care of showing the window. But before doing that we need to tell the mainWindow to not show when we init a new BrowserWindow.
Now we need to tell it to show on the ready-to-show event. Put these lines in the function createWindow in main.js.
Now the app looks like this when starting
You can read more about this in the official docs
Next tutorial is about Electron app icons.