Open Source

Electron: Build Cross-Platform Desktop Apps with JavaScript

Electron is a framework for building cross-platform desktop applications using JavaScript, HTML, and CSS, powering VS Code, Slack, and Discord.

Keeping this site alive takes effort — your support means everything.
無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分! 無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分!
Electron: Build Cross-Platform Desktop Apps with JavaScript

The desktop application landscape has been transformed by a single insight: what if you could build native-quality desktop apps using the same web technologies that power the internet? Electron made that vision a reality, and in doing so, it became the backbone of modern desktop software development.

Electron is the open-source framework that combines Chromium’s rendering engine with the Node.js runtime, allowing developers to build cross-platform desktop applications using JavaScript, HTML, and CSS. Created initially by GitHub for the Atom editor, Electron was later handed over to the OpenJS Foundation and has since become one of the most influential open-source projects in existence.

The numbers are staggering: Electron powers Visual Studio Code (100M+ monthly users), Slack, Discord, Figma, Notion, WhatsApp Desktop, Signal, Microsoft Teams, and thousands of other applications across every conceivable category. It has enabled countless startups to ship desktop applications alongside their web products without maintaining separate native codebases.


How Does Electron’s Architecture Work?

Electron’s architecture is built on a multi-process model inherited from Chromium, with two primary process types working in tandem.

graph TD
    A[Main Process\nNode.js Runtime] --> B[BrowserWindow 1\nChromium Renderer]
    A --> C[BrowserWindow 2\nChromium Renderer]
    A --> D[BrowserWindow N\nChromium Renderer]
    B --> E[IPC: ipcMain / ipcRenderer]
    C --> E
    D --> E
    E --> F[Main Process Handlers\nFile System, Native APIs]
    A --> G[System Tray]
    A --> H[Native Menu]
    A --> I[Dock / Taskbar]

The main process runs as a full Node.js environment, managing application lifecycle, native menus, system trays, and IPC (Inter-Process Communication). Each renderer process is a separate Chromium instance that displays the HTML/CSS/JavaScript UI. This separation provides both performance isolation and security boundaries.


What Applications Are Built with Electron?

Electron’s adoption spans the entire software industry, from developer tools to communication platforms to creative suites.

ApplicationCategoryUsers / Impact
Visual Studio CodeCode Editor100M+ monthly active users
SlackTeam Communication10M+ daily active users
DiscordVoice/Text Chat150M+ monthly active users
Figma DesktopDesign4M+ users (hybrid web + desktop)
Signal DesktopEncrypted Messaging40M+ monthly active users
Notion DesktopProductivity30M+ users

The breadth of adoption across such diverse use cases demonstrates Electron’s versatility for everything from lightweight chat applications to performance-intensive code editors.


What Are Electron’s Key APIs and Capabilities?

Electron provides a comprehensive set of APIs that bridge the gap between web applications and native desktop functionality.

API CategoryExamplesDescription
Window managementBrowserWindow, frameless windowsNative window controls, transparent windows, vibrancy effects
OS integrationTray, Notification, Menu, ShellSystem tray icons, native notifications, context menus
File systemdialog.showOpenDialog, net.requestNative file dialogs, HTTP requests, protocol handlers
HardwaredesktopCapturer, screenScreen recording, display info, media access
Systemapp, process, clipboardApp lifecycle, clipboard access, environment detection

These APIs are accessible through Electron’s IPC system, which provides secure, structured communication between the main and renderer processes using ipcMain and ipcRenderer.


What Are the Security Best Practices for Electron?

Security in Electron applications follows a defense-in-depth approach, recognizing that renderer processes are potentially untrusted environments.

PracticeImplementation
Context IsolationcontextIsolation: true in BrowserWindow options
Node IntegrationnodeIntegration: false in renderers (default since v5)
Content Security PolicyHTTP headers restricting script sources
IPC ValidationAlways validate IPC message payloads on the main process
SandboxingEnable renderer sandbox sandbox: true for untrusted content

Following these practices ensures that even if a renderer process is compromised (e.g., through a malicious third-party script), the attacker cannot access Node.js APIs or the operating system directly.


FAQ

What is Electron? Electron is an open-source framework developed by OpenJS Foundation for building cross-platform desktop applications using web technologies – JavaScript, HTML, and CSS. It combines Chromium’s rendering engine with Node.js runtime, allowing developers to create native desktop apps from a single codebase that runs on macOS, Windows, and Linux.

What major applications are built with Electron? Electron powers many of the most popular desktop applications, including Visual Studio Code (Microsoft), Slack, Discord, Postman, Figma (desktop app), Notion, WhatsApp Desktop, Signal, GitHub Desktop, Microsoft Teams, Twitch, WordPress.com, and many more. VS Code alone has over 100 million monthly active users.

How does Electron differ from other cross-platform frameworks? Unlike native frameworks (SwiftUI, WinUI, GTK) or other cross-platform solutions (Qt, wxWidgets), Electron uses web technologies and a full Chromium browser instance per window. This trades some memory usage for massive developer productivity, enabling web developers to build desktop apps without learning platform-specific languages or APIs.

What is the security model of Electron? Electron uses a multi-process architecture similar to Chrome, with a main process (Node.js) and renderer processes (Chromium). Security best practices include enabling context isolation, disabling Node.js integration in renderers, using Content Security Policy headers, and implementing proper IPC communication between processes.

Can Electron apps access native operating system APIs? Yes, Electron provides extensive APIs for native functionality including system tray, notifications, file system access, shell integration, clipboard access, global shortcuts, dock/badge integration, native menus, touch bar, and taskbar progress indicators. Additional native capabilities can be added through Native Node.js modules.


Further Reading

TAG
CATEGORIES