electron
teachingai/full-stack-skills
Build cross-platform desktop applications with Electron using main/renderer processes, IPC, and native features.
What is electron?
This skill covers building desktop applications with Electron, including process architecture, inter-process communication, window management, menus, tray icons, packaging, and security. Use it when creating cross-platform desktop apps or implementing Electron features.
- Scaffold and configure Electron projects with proper main/renderer process separation
- Implement secure IPC (Inter-Process Communication) between main and renderer processes using preload scripts
- Create and manage BrowserWindow instances with native features like menus, tray icons, and dialogs
- Package and distribute applications using Electron Forge or electron-builder
- Apply security best practices including context isolation and disabling nodeIntegration
- Debug and test Electron applications across Windows, macOS, and Linux
How to install electron
npx skills add https://github.com/teachingai/full-stack-skills --skill electron- Node.js and npm installed
- Basic JavaScript knowledge
- Understanding of process-based architecture helpful but not required
How to use electron
- 1.Identify your task from the available topics: getting started, main/renderer processes, IPC communication, BrowserWindow, menus, tray, packaging, or security
- 2.Load the appropriate example file from examples/ directory matching your topic
- 3.Follow the code examples and best practices in that file for your implementation
- 4.Reference the api/ directory for detailed API documentation when needed
- 5.Use provided templates for main.js, preload.js, and package.json as starting points
- 6.Test your implementation across target platforms (Windows, macOS, Linux)
Use cases
- Building a cross-platform desktop application from scratch with Electron Forge
- Implementing secure communication between main process and renderer UI using IPC handlers
- Creating system tray applications with context menus and window management
- Packaging an Electron app for distribution with auto-updates
- Adding native OS features like file dialogs and system notifications to a desktop app
- Full-stack developers building desktop applications
- Frontend developers extending web apps to desktop
- Teams needing cross-platform desktop solutions
- Developers implementing Electron in production applications
electron FAQ
Use IPC with preload scripts: expose safe APIs via contextBridge in preload.js, then use ipcRenderer.invoke() in renderer and ipcMain.handle() in main process. Always disable nodeIntegration and enable contextIsolation in BrowserWindow webPreferences.
The main process manages application lifecycle and native OS integration; renderer processes run the UI in isolated BrowserWindow instances. They communicate only through IPC to maintain security boundaries.
Use Electron Forge (recommended) or electron-builder to handle packaging, code signing, and platform-specific builds. Both tools automate creating installers for Windows, macOS, and Linux.
Never enable nodeIntegration in renderer, always enable contextIsolation, use preload scripts for exposing APIs, validate all IPC messages, and keep Electron updated. Avoid loading untrusted remote content.
Yes, but native modules must be compiled for Electron's Node version. Use electron-rebuild to recompile native dependencies after installing, and test on all target platforms.
Full instructions (SKILL.md)
Source of truth, from teachingai/full-stack-skills.
name: electron description: "Build cross-platform desktop applications with Electron, covering main/renderer process architecture, IPC communication, BrowserWindow management, menus, tray icons, packaging, and security best practices. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps." license: Complete terms in LICENSE.txt
When to use this skill
Use this skill whenever the user wants to:
- Build cross-platform desktop applications with Electron
- Understand Electron architecture (main process, renderer process, preload)
- Implement IPC (Inter-Process Communication) between processes
- Create and manage BrowserWindow instances
- Implement menus, tray icons, and native features
- Package and distribute Electron applications
- Use Electron Forge for project scaffolding and building
- Debug and test Electron applications
- Implement security best practices
- Use Electron APIs (app, BrowserWindow, ipcMain, ipcRenderer, etc.)
How to use this skill
This skill is organized to match the Electron official documentation structure (https://www.electronjs.org/zh/docs/latest/, https://www.electronjs.org/zh/docs/latest/api/app). When working with Electron:
-
Identify the topic from the user's request:
- Getting started/快速开始 →
examples/getting-started/installation.mdorexamples/getting-started/quick-start.md - Main process/主进程 →
examples/processes/main-process.md - Renderer process/渲染进程 →
examples/processes/renderer-process.md - IPC communication/IPC 通信 →
examples/processes/ipc-communication.md - BrowserWindow/窗口 →
examples/api/browser-window.md - Menu/菜单 →
examples/api/menu.md - Packaging/打包 →
examples/advanced/packaging.md - Security/安全 →
examples/advanced/security.md
- Getting started/快速开始 →
-
Load the appropriate example file from the
examples/directory:Getting Started (快速开始) -
examples/getting-started/:examples/getting-started/installation.md- Installing Electron and basic setupexamples/getting-started/quick-start.md- Quick start tutorial
Processes (进程) -
examples/processes/:examples/processes/main-process.md- Main process concepts and usageexamples/processes/renderer-process.md- Renderer process conceptsexamples/processes/preload-scripts.md- Preload scripts usageexamples/processes/ipc-communication.md- IPC communication patterns
API Examples (API 示例) -
examples/api/:examples/api/browser-window.md- BrowserWindow usageexamples/api/menu.md- Menu and context menuexamples/api/tray.md- System trayexamples/api/dialog.md- File dialogsexamples/api/ipc-main.md- ipcMain usageexamples/api/ipc-renderer.md- ipcRenderer usage
Advanced (高级) -
examples/advanced/:examples/advanced/packaging.md- Application packagingexamples/advanced/security.md- Security best practicesexamples/advanced/auto-updater.md- Auto updaterexamples/advanced/native-modules.md- Native modules
Tools (工具) -
examples/tools/:examples/tools/electron-forge.md- Electron Forge usageexamples/tools/electron-fiddle.md- Electron Fiddle usage
-
Follow the specific instructions in that example file for syntax, structure, and best practices
Important Notes:
- All examples follow Electron latest API
- Examples use both CommonJS (require) and ES modules (import)
- Each example file includes key concepts, code examples, and key points
- Always check the example file for best practices and common patterns
- Electron supports Windows, macOS, and Linux
-
Reference API documentation in the
api/directory when needed:api/app.md- app module APIapi/browser-window.md- BrowserWindow APIapi/ipc-main.md- ipcMain APIapi/ipc-renderer.md- ipcRenderer APIapi/menu.md- Menu APIapi/tray.md- Tray API
-
Use templates from the
templates/directory:templates/main-process.md- Main process templatetemplates/preload-script.md- Preload script templatetemplates/renderer-process.md- Renderer process templatetemplates/package-json.md- package.json template
Doc mapping (one-to-one with official documentation)
examples/→ https://www.electronjs.org/zh/docs/latest/api/→ https://www.electronjs.org/zh/docs/latest/api/app
Quick Start Example
// main.js
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
function createWindow() {
const win = new BrowserWindow({
width: 800, height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false, // Security: always disable
contextIsolation: true // Security: always enable
}
})
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
// IPC handler example
ipcMain.handle('get-data', async () => {
return { message: 'Hello from main process' }
})
// preload.js
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('api', {
getData: () => ipcRenderer.invoke('get-data')
})
API Reference (api/)
api/app.md- app module APIapi/browser-window.md- BrowserWindow APIapi/ipc-main.md/api/ipc-renderer.md- IPC APIsapi/menu.md/api/tray.md/api/dialog.md- UI APIs
Best Practices
- Security: Never enable nodeIntegration in renderer process, use preload scripts
- Process separation: Keep main and renderer processes separate
- IPC communication: Use IPC for safe communication between processes
- Resource management: Properly clean up resources (windows, listeners)
- Error handling: Implement proper error handling and crash reporting
- Performance: Optimize for performance, use webContents for debugging
- Packaging: Use Electron Forge or electron-builder for packaging
- Auto updates: Implement auto-updater for production apps
- Native modules: Handle native module compatibility
- Cross-platform: Test on all target platforms
Resources
- Official Website: https://www.electronjs.org/zh/
- Documentation: https://www.electronjs.org/zh/docs/latest/
- API Reference: https://www.electronjs.org/zh/docs/latest/api/app
- Electron Forge: https://www.electronforge.io
- Electron Fiddle: https://www.electronjs.org/zh/fiddle
- GitHub Repository: https://github.com/electron/electron
Keywords
Electron, desktop app, main process, renderer process, preload, IPC, BrowserWindow, Menu, Tray, Dialog, packaging, electron-builder, electron-forge, electron-fiddle, cross-platform, 桌面应用, 主进程, 渲染进程, IPC 通信, 窗口, 菜单, 托盘, 打包
Related skills
More from teachingai/full-stack-skills and the wider catalog.

element-plus-vue3
Vue 3 component library with 60+ UI components, theming, and i18n support.

uniapp-project
Provides per-component and per-API examples with cross-platform compatibility details for uni-app, covering built-in components, uni-ui components, and APIs (network, storage, device, UI, navigation, media). Use when the user needs official uni-app components or APIs, wants per-component examples with doc links, or needs platform compatibility checks.

drawio-flowchart
Creates flowcharts, swim lane diagrams, and business process diagrams using Draw.io (diagrams.net). Covers standard flowchart shapes (process, decision, start/end), connectors, auto-layout, and export to PNG/SVG/PDF. Use when the user needs to visualize workflows, decision trees, or business processes.

temporal-developer
Develop, debug, and manage durable workflows across Python, TypeScript, Go, Java, .NET, Ruby, and Rust using Temporal.

weread-skills
Search, manage, and explore WeChat Reading books with notes, reviews, and personalized recommendations.

ai-model-nodejs
Call AI models from Node.js backends, cloud functions, and CloudRun with image generation support.