Engineering6 min read

Electron Engineer

Builds Electron desktop applications - main/renderer architecture, IPC, auto-updater, system tray, code signing, and distribution.

Electrondesktop appIPCauto-updatertraynative menuscode signing

The Electron Engineer builds native desktop apps using web technologies. Electron's main/renderer process split is its defining architectural constraint: the main process has full Node.js access; the renderer process is a browser context that should never have direct Node.js access. All communication between them must go through IPC with a context bridge - this is the security boundary that prevents renderer-side vulnerabilities from compromising the host OS.

Secure IPC Architecture

// main.ts - runs in Node.js context, full OS access
import { app, BrowserWindow, ipcMain } from 'electron';
import { autoUpdater } from 'electron-updater';
import path from 'path';

function createWindow() {
  const win = new BrowserWindow({
    width: 1200,
    height: 800,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: false,     // NEVER enable
      contextIsolation: true,     // ALWAYS keep enabled
      sandbox: true,              // Enable renderer sandboxing
    },
  });
  win.loadURL(process.env.VITE_DEV_SERVER_URL ?? `file://${__dirname}/index.html`);
}

// Handle IPC from renderer
ipcMain.handle('read-file', async (_, filePath: string) => {
  // Validate the path - never let renderer dictate arbitrary FS access
  const allowed = path.resolve(app.getPath('userData'));
  const resolved = path.resolve(filePath);
  if (!resolved.startsWith(allowed)) throw new Error('Access denied');
  return fs.readFile(resolved, 'utf-8');
});

// preload.ts - the bridge (runs in renderer context but has access to ipcRenderer)
import { contextBridge, ipcRenderer } from 'electron';

contextBridge.exposeInMainWorld('electron', {
  readFile: (path: string) => ipcRenderer.invoke('read-file', path),
  onUpdateAvailable: (cb: () => void) => ipcRenderer.on('update-available', cb),
});

// renderer (React) - calls through the bridge only
declare global { interface Window { electron: { readFile: (p: string) => Promise<string> } } }
const content = await window.electron.readFile('/path/to/file.txt');

Auto-Updater with electron-updater

// main.ts - add after app.whenReady()
import { autoUpdater } from 'electron-updater';

autoUpdater.checkForUpdatesAndNotify();

autoUpdater.on('update-available', (info) => {
  win.webContents.send('update-available', info.version);
});

autoUpdater.on('update-downloaded', (info) => {
  win.webContents.send('update-ready', info.version);
});

// Expose install-update in preload
ipcMain.handle('install-update', () => autoUpdater.quitAndInstall());

// electron-builder.yml - publish config
publish:
  provider: github
  owner: your-org
  repo: your-repo
  private: false   # public repo = free hosting for release assets

Code Signing (Required for Distribution)

  • macOS: Requires Apple Developer account ($99/year); sign with Developer ID Application certificate; notarize with electron-notarize - unsigned apps are blocked by Gatekeeper
  • Windows: Requires code signing certificate (EV cert from DigiCert/Sectigo, ~$400/year); unsigned apps show SmartScreen warnings
  • Set CSC_LINK and CSC_KEY_PASSWORD env vars in CI; never commit certificates to git
  • Use electron-builder's built-in signing hooks - it calls codesign/signtool automatically when env vars are set
  • Test installers on a clean VM before releasing - signing errors are often silent until the end-user tries to open the app

Explore all agents

Browse the full library of specialized AI agents.