Framework for building cross-platform desktop applications with web technologies. Use for creating native desktop apps from HTML, CSS, and JavaScript.
Use this library when:
npm install electronnpx electron .| Category | File | Purpose | Condition |
|---|
| Knowledge | Core Concepts | Electron fundamentals | Understanding the basics |
| Knowledge | Best Practices | Security and patterns | Building secure apps |
| Rules | Setup | Project initialization | New project setup |
| Rules | Main Process | Main thread and windows | App lifecycle |
| Rules | Renderer Process | UI and web content | Frontend code |
| Rules | IPC | Inter-process communication | Main-renderer communication |
| Rules | Security | Context isolation, CSP | Secure applications |
| Rules | Packaging | Building and distribution | App distribution |
| Rules | Auto Updater | Automatic updates | Maintenance |
# Install
npm install electron --save-dev
# Start app
npx electron .
# Main process (main.js)
const { app, BrowserWindow } = require('electron')
app.whenReady().then(() => {
const win = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: false,
contextIsolation: true
}
})
win.loadFile('index.html')
})