Loading...
Loading...
Expert in building cross-platform desktop applications using web technologies (HTML/CSS/JS) with the Electron framework.
npx skill4agent add 404kidwiz/claude-supercode-skills electron-proHow to structure the app?
│
├─ **Security First (Recommended)**
│ ├─ Context Isolation? → **Yes** (Standard since v12)
│ ├─ Node Integration? → **No** (Never in Renderer)
│ └─ Preload Scripts? → **Yes** (Bridge API)
│
├─ **Data Persistence**
│ ├─ Simple Settings? → **electron-store** (JSON)
│ ├─ Large Datasets? → **SQLite** (`better-sqlite3` in Main process)
│ └─ User Files? → **Native File System API**
│
└─ **UI Framework**
├─ React/Vue/Svelte? → **Yes** (Standard SPA approach)
├─ Multiple Windows? → **Window Manager Pattern**
└─ System Tray App? → **Hidden Window Pattern**| Pattern | Method | Use Case |
|---|---|---|
| One-Way (Renderer → Main) | | logging, analytics, minimizing window |
| Two-Way (Request/Response) | | DB queries, file reads, heavy computations |
| Main → Renderer | | Menu actions, system events, push notifications |
security-auditornodeIntegration: truecontextIsolationhttps://remoteelectron-linkv8-compile-cacherequire()main.ts// Bad
import { heavyLib } from 'heavy-lib';
// Good
ipcMain.handle('do-work', () => {
const heavyLib = require('heavy-lib');
heavyLib.process();
});esbuildwebpack// main.ts
import { Worker } from 'worker_threads';
ipcMain.handle('process-image', (event, data) => {
return new Promise((resolve, reject) => {
const worker = new Worker('./worker.js', { workerData: data });
worker.on('message', resolve);
worker.on('error', reject);
});
});myapp://open?id=123// main.ts
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('myapp', process.execPath, [path.resolve(process.argv[1])]);
}
} else {
app.setAsDefaultProtocolClient('myapp');
}
app.on('open-url', (event, url) => {
event.preventDefault();
// Parse url 'myapp://...' and navigate renderer
mainWindow.webContents.send('navigate', url);
});app-region: drag