Building Desktop Applications with the Electron Framework – Part 2

In part 1, we discussed how desktop applications are still in vogue and a few challenges in building them. In this electron tutorial, we take a closer look at how Electron development works and its associated processes. We also describe how to install and get started with Electron development and package and distribute applications. Lastly, we cover a few important resources that will aid you in strengthening your Electron development toolkit.

How Electron Works?

An Electron application has two types of processes – Main and Renderer processes.
In Electron, there is always one Main process and has access to the main script. It also has access to a huge distinct subset of the Electron API. Since there is only one Main process, it can display a GUI by creating web pages.
In a normal browser, webpages run inside a sandboxed environment that disallows access to the underlying native OS resources. Electron development, however, can use Node.js API’s to gain access to these powerful lower-level resources.
The Renderer process is responsible for creating the DOM of the web app. While the Renderer process can use Node.js API’s they do not have access to operating system-level resources. The Renderer process of the webpage requests these using the Main process which then accesses these resources on its behalf.
electron-2-1

Communication between processes

The Main and Renderer process communicates using Interprocess Communication or IPC for short. The ipcMain and ipcRenderer modules handle communication between the Main and Renderer process. These modules are part of the Electron core. These processes can also communicate using the remote module for RPC style communication.
The ipcMain enables communication from the Main to the Renderer process, while the ipcRenderer handles communication in the opposite direction from the Renderer to the Main.
electron-2-2

Building Offline Applications

‘Offline first’ is a must for any progressive web app (PWA). This essentially augments the purpose of a native desktop app making it usable when no network connectivity exists. With access to Node.js, any module can read and store data on a local operating system. In a situation where network connectivity is not available, the application can ‘communicate’ with the local storage and database.
electron-2-3

Installation and quick start

We can use “npm” to install prebuilt Electron binaries. The preferred method is to install Electron as a development dependency in your app.

We can also use the below command to install electron as a global package.

Once installed, run the command below for a quick start.

Packaging and distribution

Several third-party tools exist for packaging and distributing Electron-made apps.

  • Electron-builder
  • Electron-packager
  • Electron-forge


Chances are you are already using an Electron-made app today. Here are a couple more that were made with Electron:

Further reading and references:

Learn More about Encora

We are the software development company fiercely committed and uniquely equipped to enable companies to do what they can’t do now.

Learn More

Global Delivery

READ MORE

Careers

READ MORE

Industries

READ MORE

Related Insights

Enabling Transformation in Hospitality through Technology-Led Innovation

As the exclusive sponsor of the 2024 Hotel Visionary Awards, we support organizations leading ...

Read More

Key Insights from HLTH 2024: The Future of Patient-Centered Healthcare

Discover key insights from HLTH 2024 on digital health, AI in diagnostics, data interoperability, ...

Read More

Data-Driven Engineering: Transforming Operations and Products from Insight to Impact

Discover how data-driven engineering transforms operations and product development, enhancing team ...

Read More
Previous Previous
Next

Accelerate Your Path
to Market Leadership 

Encora logo

Santa Clara, CA

+1 669-236-2674

letstalk@encora.com

Innovation Acceleration

Speak With an Expert

Encora logo

Santa Clara, CA

+1 (480) 991 3635

letstalk@encora.com

Innovation Acceleration