desktop

Guide Electron desktop app architecture with main, renderer, and preload processes.

81.4k|15.8k|Updated May 21, 2023
One-click install
npx skills add https://github.com/lobehub/lobehub --skill desktop-lobehub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: desktop
Source: https://github.com/lobehub/lobehub/tree/main/.agents/skills/desktop
Command: npx skills add https://github.com/lobehub/lobehub --skill desktop-lobehub

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to building Electron desktop applications, including setting up main and renderer processes, secure IPC, preload scripts, window management, and menus, to accelerate robust desktop feature development.

Core Features & Use Cases

  • Architecture overview: main process, renderer process, and preload
  • Feature implementation guidance: IPC handlers, window management, and menu configuration
  • Best practices: security, performance, UX, and cross-platform considerations
  • Use Case: building a desktop app with secure IPC communication between processes for a dynamic user workflow.

Quick Start

Install Node.js and npm, install project dependencies, and run the desktop app in development mode using your project's usual Electron startup command. Start by exploring the main process file structure under apps/desktop/src/main and the renderer under apps/desktop/src/renderer, then follow the step-by-step guides in references.

Frequently Asked Questions about desktop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up secure IPC communication between an Electron main process and renderer?

Secure IPC in Electron is established by using preload scripts to expose a controlled, minimal API to the renderer process. This architecture prevents direct access to Node.js APIs, ensuring safe communication between the main and renderer processes.

What is the difference between the main process and preload script in an Electron desktop app?

The main process manages windows and native OS menus, while the preload script acts as a secure bridge. Preload scripts run before the renderer loads, safely exposing specific IPC handlers to the web page without granting direct Node.js access.

How do I get started building a cross-platform desktop application with Electron?

Start building an Electron desktop application by installing Node.js and npm, then configuring your project dependencies. Explore the main process structure under src/main and the renderer under src/renderer, following step-by-step guides to implement core features.

Does Electron support native window and menu management for desktop apps?

Yes, Electron supports native window and menu management. The framework provides comprehensive APIs within the main process to configure application menus and control window lifecycle, enabling robust desktop UX across different operating systems.

What are the security best practices for Electron preload scripts and renderer processes?

Security best practices for Electron involve isolating the renderer process and using preload scripts to define a strict IPC API. This prevents renderer code from directly accessing Node.js modules, mitigating cross-platform desktop application vulnerabilities.