Blog Articles

Auto Update

Electron App Revolution: Enhance with Automatic Updates

blog image

Electron App Revolution: Enhance with Automatic Updates

Stay ahead in Electron app development with Innostax's expert insights on auto-updating features. Streamline app updates seamlessly.

Electron App Revolution: Enhance with Automatic Updates
Sahil Khurana
Published: February 7, 2024

Key takeaways

  1. Electron integrates Chromium with Node, which creates applications for the platform of desktops across. js, with basic files that are likely to be important such as index. html, preload. js, and main. js to organize application and its extensions and to contain specific functions and looks.

  2. Electron has seven processes altogether: main and renderer in particular; the interaction between them is possible with the help of IPC modules, such as ipcMain and ipcRenderer for Node.js. js APIs and HTML DOM as the main conceptual areas of interest among the students of computer science.

  3. Electron app distribution contains code signing and auto-update capabilities, utilities such as electron-forge and electron-builder help in creating releases on GitHub and guarantee app consistence between macOS and Windows.

Introduction

Electron is a framework used for building the cross platform desktop application by binding Chromium and NodeJs.

Electron Fiddle

A tool or sandbox application used to perform experiments on Electron APIs or prototypes. If you have installed it then you can execute code using the Fiddle Editor button without copy paste the code.

File Structure of Electron App

In case of file structure, it has basically “index.html”, “preload.js” and “main.js”. Initially, when you start the development for an electron app you can use the “index.html” and “main.js” files only. In “index.html” file has the default content of the application and in “preload.js” add the functionality to load the custom components. And in the “main.js” file use the application methods and perform custom functions.

  • Create a directory
    electron-1
  • Change directory and give npm command
    electron-2
    electron-3
  • Now create an “index.html” file in the above created directory and place the code.
    electron-4
    electron-11
  • create an “main.js” file in the above created directory and place the code.
    electron-12
  • Finally, after running the “npm start” command, you can see the home screen of the application.


Electron Process

Electron has two main processes which are main and renderer processes, these have different responsibilities and are not interchangeable.

  • Renderer Process – The renderer process is used to access the HTML DOM.
  • Main Process – The main process is used to access the NodeJs APIs.

IPC (Inter-Process Communication) Modules

Inter-process communication modules are used to communicate between the main process and the renderer processes. We can use the “ipcMain” and “ipcRenderer” modules.

Packaging

The packaging phase comes before distributing the electron app among the users. 

Code Signing

The code signing process is certifying that the particular desktop application is created by a known source. If you have code signing certificates for windows and macOS then set the certificates in the respective configuration file. Windows and macOS have different signing systems.

macOS

Code signing is done at the application packaging level.

Windows

Distributable installer is signed.

Auto Update

Auto-update feature is provided by the Electron maintainers as free. But it has some conditions to follow:

  • The app should be capable of running on macOS and Windows.
  • The app should have a public github repo and can do work with private too but need to add credentials in the environment variables in that case.
  • Builds should be published to GitHub releases.
  • Builds should be code signed.

Github Publishers

Github publishers are used to publish the electron app. We have a choice with electron-forge and electron-builder, whereas electron-builder comes with full  functionality flow but electron-forge has some limitations.  And to work with this we need to add it as a dependency in the project by using the below NPM command.

electron-forge

electron-4

To configure the publisher in the forge, you need to update the forge.config.js file. Add the github repository details in the configuration file of the forge, for which you will need the name of the repository and owner name (See the settings of the github).

electron-5

Finally, you will have to add the script in the package. json file.

electron-builder

electron-6

Then, you will need to update the package.json file with this,

Add script in the package.json file 

The same task we do by using the Github workflow.

Release

After successful execution of the script, you can see the releases on Github .

Sign Up Now
Get a Fast Estimate on Your Software Development Project

We are committed to delivering high-quality IT solutions tailored to meet the unique needs of our clients. As part of our commitment to transparency and excellence, we provide detailed project estimations to help our clients understand the scope, timeline, and budget associated with their IT initiatives.