First steps with Electron app

Electron is a popular framework for building cross-platform desktop applications using web technologies such as HTML, CSS, and JavaScript. Creating a custom Electron app involves using the Electron APIs and tools to build and package a web application as a desktop app.

Here are the steps for creating a custom Electron app: Install Node.js and the Electron CLI on your development machine. Node.js is a JavaScript runtime that is required to run Electron, and the Electron CLI is a command-line tool for creating, building, and packaging Electron apps. You can install these tools using the following commands:

# Install Node.js
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

# Install the Electron CLI
npm install -g electron

Create a new directory for your Electron app and initialize it with a package.json file. The package.json file is used to define the metadata and dependencies of your Electron app, and is required for building and packaging the app. You can create a new directory and initialize it with a package.json file using the following commands:
# Create a new directory for your Electron app
mkdir my-electron-app
cd my-electron-app

# Initialize the directory with a package.json file
npm init -y

Create the main JavaScript file for your Electron app. The main JavaScript file is the entry point for your Electron app, and it is responsible for creating the main window, loading the web application, and handling other app-level events. Here is an example of a simple main JavaScript file for an Electron app:
const { app, BrowserWindow } = require('electron')

function createWindow () {
  // Create the browser window.
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true

  // and load the index.html of the app.

  // Open the DevTools.

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {

app.on('activate', () => {
  // On macOS it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (BrowserWindow.getAllWindows().length === 0) {

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

Publish your electron app in seconds

After you have created a custom Electron app, you can publish it to make it available for users to download and install. Here are the steps for publishing an Electron app:

Create a binary or installer package for your Electron app. Electron apps are distributed as binary or installer packages, which contain the app code and dependencies, as well as any additional files and resources needed by the app. To create a binary or installer package for your Electron app, you can use the electron-packager or electron-builder npm modules. For example, to create a binary package for a MacOS app using electron-packager, you can run the following command:

# Install the electron-packager npm module
npm install electron-packager --save-dev

# Create a binary package for the app
./node_modules/.bin/electron-packager . --platform=darwin --arch=x64 --icon=icon.icns --out=dist

Create a landing page or website for your Electron app. A landing page or website is a place where users can learn more about your app, download and install it, and get support. You can use a static website generator or a platform like GitHub Pages to create a simple website for your app.

Publish your Electron app on a platform or marketplace. There are many platforms and marketplaces where you can publish your Electron app, such as the Apple App Store, the Microsoft Store, and the GitHub Releases page. Each platform has its own requirements and processes for publishing apps, so you will need to follow their guidelines to submit and publish your app.

Promote your Electron app. After your app is published, you can promote it to reach more users and increase its visibility and download numbers. You can use social media, email marketing, and other online channels to promote your app and drive traffic to your landing page or website.

These are the general steps for publishing an Electron app. The exact process will depend on the specific requirements and goals of your app, as well as the platform or marketplace where you are publishing it.

Edit this page on GitHub Updated at Thu, Dec 15, 2022