This project now includes full Electron support for building standalone desktop applications for Windows, macOS, and Linux.
-
electron/main.js - Main Electron process
- Window management (creation, sizing, behavior)
- Menu configuration with native menus
- Security settings (context isolation, disabled node integration)
- IPC handlers for renderer-main communication
- Platform-specific handling (macOS vs Windows vs Linux)
-
electron/preload.js - Preload script
- Exposes safe API to renderer via contextBridge
- Provides version info and platform detection
-
build/entitlements.mac.plist - macOS code signing entitlements
- Required for network access
- Enables JIT for V8
- Hardened runtime support
package.json:
- Added
"main": "electron/main.js"entry point - Added Electron scripts:
electron:dev- Development mode with hot reloadelectron:build- Build for all platformselectron:build:win- Windows-specific buildelectron:build:mac- macOS-specific build
- Added electron-builder configuration for all platforms
- Added dependencies: electron, electron-builder, concurrently, wait-on, electron-is-dev
vite.config.ts:
- Changed server port from 3000 to 5173 (Electron default)
- Added
base: './'for file:// protocol support
types.ts:
- Added ElectronAPI interface for type-safe renderer communication
.gitignore:
- Added
release/to ignore built binaries
Windows (x64):
- NSIS installer (
.exe) with customization options - Portable executable (
.exe)
macOS (x64 + arm64):
- DMG disk image (
.dmg) - ZIP archive (
.zip) - Code signing with hardened runtime
Linux:
- AppImage (universal)
- Debian/Ubuntu package (
.deb)
npm run electron:devThis starts:
- Vite dev server on http://localhost:5173
- Electron window loading the dev server
- Hot reload enabled
All platforms:
npm run electron:buildWindows only:
npm run electron:build:winmacOS only:
npm run electron:build:macAll built applications are placed in the release/ directory.
- Windows 10 or later
- No additional dependencies
- Builds run on Windows or can be cross-compiled from Linux/macOS
- macOS 10.15 (Catalina) or later
- Xcode Command Line Tools:
xcode-select --install - For App Store distribution: Apple Developer account
- For signed distribution outside App Store: Apple Developer certificate
- Any modern distribution
- Build tools:
sudo apt-get install build-essential
- Context Isolation: Enabled (prevents prototype pollution)
- Node Integration: Disabled in renderer
- Content Security Policy: Configurable in electron/main.js
- Preload Script: Secure API exposure
- Electron Security Best Practices: Following official guidelines
- Ensure Windows SDK is installed
- Run as administrator if permission errors occur
- Check that no instances of the app are running
- Install Xcode Command Line Tools:
xcode-select --install - Ensure code signing certificates are set up (for distribution)
- Check macOS version compatibility
- Ensure
dist/directory exists (runnpm run buildfirst) - Check that all files are included in electron-builder config
- Check console logs in DevTools (in development mode)
- Verify all API keys are properly configured in .env.local
- Check that required services are accessible
- Builds work out of the box for testing
- macOS will show "unidentified developer" warning
- Right-click → Open on macOS to bypass (once)
- Requires Apple Developer certificate (macOS)
- Requires code signing certificate (Windows)
- Configure in electron-builder options:
"mac": { "identity": "Developer ID Application: Your Name" }
┌─────────────────────────────────────────┐
│ Electron Main Process │
│ (electron/main.js) │
│ - Window management │
│ - OS integration │
│ - Security │
└─────────────────────────────────────────┘
↕ IPC
┌─────────────────────────────────────────┐
│ Preload Script │
│ (electron/preload.js) │
│ - ContextBridge API │
│ - Secure communication │
└─────────────────────────────────────────┘
↕ Exposed API
┌─────────────────────────────────────────┐
│ Renderer Process │
│ (Your React app) │
│ - UI/UX │
│ - Business logic │
│ - API calls to AI providers │
└─────────────────────────────────────────┘
- Test locally: Run
npm run electron:devto verify everything works - Build for your platform: Run the appropriate build command
- Test the built app: Install/run the output from
release/ - Customize appearance: Modify icon, window size, branding in electron/main.js
- Configure code signing: Set up certificates for production builds
- Distribute: Share the built installers with users
For issues specific to Electron or electron-builder, refer to:
- Electron docs: https://www.electronjs.org/docs
- electron-builder docs: https://www.electron.build/