This is being typed in Atom, GitHub’s open-source, hackable, extensible text editor, almost IDE. It works great and cross-platform. Atom is built on Electron, which can very roughly be simplified to a stand-alone web page (backed by Chromium, thus cross-platform). I recently learned that Microsoft’s Visual Studio Code IDE is also based on Electron.

So, two great products being built on the same platform, I wanted to check it out more.

It’s quite easy to get started building your first cross-platform app with Electron. I will provide a simple walkthrough with all the necessary code shown. Less important details are left out on this page so that the focus can be more on getting something up and running visually.

Prerequisites: Node.js and npm already installed on the computer.

How to create app in Electron

  1. Create a new directory for your project.
  2. Create three files in that directory: ‘package.json’, ‘main.js’, and ‘index.html’.

    1. In ‘package.json’, add the following:

         "name": "my-app",
         "version": "0.1.0",
         "main": "main.js",
         "scripts": {
           "start": "electron ."
    2. In ‘index.html’, add the following:

       <!DOCTYPE html>
           <title>My App Name</title>
           <h1 align="center">Hello World!</h1>
           We are using io.js <script>document.write(process.version)</script>
           and Electron <script>document.write(process.versions['electron'])</script>.
    3. In ‘main.js’, add the following:

       var app = require('app') // Module to control application life.
       var BrowserWindow = require('browser-window') // Module to create native browser window.
       // Keep a global reference of the window object, if you don't, the window will
       // be closed automatically when the JavaScript object is GCed.
       var mainWindow = null;
       // This method will be called when Electron has finished
       // initialization and is ready to create browser windows.
       app.on('ready', function() {
         // Create the browser window.
         mainWindow = new BrowserWindow({width: 800, height: 600});
         // and load the index.html of the app.
         mainWindow.loadUrl('file://' + __dirname + '/index.html'); //__
         // Emitted when the window is closed.
         mainWindow.on('closed', function() {
           // Dereference the window object, usually you would store windows
           // in an array if your app supports multi windows, this is the time
           // when you should delete the corresponding element.
           mainWindow = null;
  3. Run ‘npm install electron-prebuilt –save-dev’
  4. Run ‘npm start’

Source and more info: tutorial/quick-start

This the quickest I’ve ever built a cross-platform application. For more of my notes on Electron, see by GitHub dev repo.

Now a quick word from a tech company who helps support me and this site: