Electron hello world

First, install Electron via NPM:

$ npm init -y
$ npm install --save electron

Then create a web page to display in index.html:

<!DOCTYPE html><html><body>Hello World!</body></html>

Then create main.js, your app’s entry point, which loads that web page in an Electron window:

const {app, BrowserWindow} = require('electron');

// Keep a global reference.
// A windows is closed when its object is GC'd!
let mainWindow;

app.on('ready', () => {
  mainWindow = new BrowserWindow({});
  mainWindow.loadFile('index.html');
  mainWindow.on('closed', () => app.quit());
});

Finally, run your app with the electron binary:

$ ./node_modules/.bin/electron .

If all goes well, you’ll get a new window which says “Hello world!”.

I just released Vidrio, a free app for macOS and Windows to make your screen-sharing awesomely holographic. Vidrio shows your webcam video on your screen, just like a mirror. Then you just share or record your screen with Zoom, QuickTime, or any other app. Vidrio makes your presentations effortlessly engaging, showing your gestures, gazes, and expressions. #1 on Product Hunt. Available for macOS and Windows.

With Vidrio

With generic competitor

More by Jim

Tagged #programming. All content copyright James Fisher 2019. This post is not associated with my employer. Found an error? Edit this page.