You can download this application from Github if you’d like. After this blog post was written i decided to rebrand it to the electron tutorial app because that name suits it better when adding more electron tutorials to it.
An electron app is built using the node.js framework and is brought to us by Github. Maybe you’ve already tested a few electron apps now. For example slack is a well know application built on electron. If you’d like to test one i can recommend Atom. In fact, why don’t you try this tutorial with that IDE?
1. Installing Node.js
First we need to install node.js. So go ahead and do that.
2. Installing electron prebuilt
Now that we have Node.js installed, let’s install electron prebuilt globally.
This makes us able to test run our electron application by running this command in our terminal. But more on this later.
2. File structure
In its most basic form an electron app needs three files. package.json, main.js, and index.html. Making the folder structure look like this:
Create a folder and add those files and let’s walk trough them one by one.
Let’s add content to package.json. We need a name, a version and a main setting that points to a script that will handle the starting up of the app. If main is not present electron will look for a file called index.js.
As mentioned above the we pointed out main.js to handle the startup of our application. Lets add this content to it. This code is borrowed from electron quick start.
The index.html takes care of the gui.
6. Running the Electron hello world app
Now let’s get back to the electron . command. That will start electron and run the app that we are currently building.
This fires up an app looking like this:
electron hello world running
As you can see we also have the chromium developer tool window opened inside our app. This is opened with this call in main.js.