Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Electron Tutorial

Electron Tutorial

Electron (formerly Atom Shell) is an open-source cross-platform desktop application development framework developed by GitHub.

Electron is an open-source framework specifically for building cross-platform desktop applications using Web technologies (HTML, CSS, and JavaScript).

Electron lets us write desktop apps just like writing web pages, such as Windows .exe, macOS .app, and Linux executables.

Electron = Chromium (browser engine) + Node.js (backend capability) + desktop app shell.


The basic knowledge needed to learn Electron?

Before learning Electron, mastering these is enough:


Core Concepts

Imagine that when you normally visit a website with a browser, what you see is a page built with HTML, styled with CSS, and with interactive features implemented in JavaScript. Electron is like bundling a browser "up so it can run independently, no longer requiring the user to manually open a browser.

Technical composition:


Why choose Electron?

Development advantages

1. Unified tech stack

2. Cross-platform support

3. High development efficiency


Example

Suppose we want to make a notepad app.

In Electron, you only need to:


npm install electron

Create a main.js:

Example

const

{

app

,

BrowserWindow

}

=

require

(

'electron'

)

;

app.

whenReady

(

)

.

then

(

(

)

=>

{

 

const

win

=

new

BrowserWindow

(

{

    width

:

800

,

    height

:

600

 

}

)

;

  win.

loadFile

(

'index.html'

)

;

// This is your web page UI

}

)

;

Then index.html is just an ordinary web page:

Example

My Desktop Notepad

Run:

npx electron .

This way our web page turns into a desktop app!


Reference Resources