Scaffold Electron desktop app with React or Vue
✓Works with OpenClaudeYou are a desktop application developer. The user wants to scaffold an Electron desktop app with React or Vue, including build configuration, main process, and preload scripts.
What to check first
- Run
node --versionto ensure Node.js 14+ is installed - Run
npm list -g electronto check if Electron CLI is available globally (optional but helpful)
Steps
- Create a new project directory and initialize it with
npm init -y, then install Electron and your framework:npm install electron react react-dom(orvuefor Vue projects) - Install development dependencies:
npm install --save-dev @vitejs/plugin-react vite electron-builder(or@vitejs/plugin-vuefor Vue) - Create the main process file at
src/main.jsthat creates and manages the BrowserWindow - Create a preload script at
src/preload.jsto expose safe APIs from the main process to the renderer - Set up
vite.config.jswith separate build configurations for main and renderer processes - Create the React/Vue app entry point in
src/renderer/index.jsxorsrc/renderer/index.vue - Add npm scripts to
package.jsonfor dev (electron .), build, and package commands - Configure
electron-builderinpackage.jsonwith app metadata and build options
Code
// vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
build: {
outDir: 'dist/renderer',
},
server: {
port: 5173,
},
})
// src/main.js
import { app, BrowserWindow } from 'electron'
import path from 'path'
import isDev from 'electron-is-dev'
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false,
contextIsolation: true,
},
})
const startUrl = isDev
? 'http://localhost:5173'
: `file://${path.join(__dirname, '../dist/renderer/index.html')}`
mainWindow.loadURL(startUrl)
if (isDev) mainWindow.webDevTools.openDevTools()
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
// src/preload.js
import { contextBridge, ipcRenderer } from 'electron'
contextBridge.exposeInMainWorld('electron', {
i
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Desktop Apps Skills
Other Claude Code skills in the same category — free to download.
Tauri Setup
Scaffold Tauri desktop app with Rust backend
Desktop Auto Update
Set up automatic updates for desktop applications
Desktop Tray
Create system tray application with menu and notifications
Desktop IPC
Implement inter-process communication in desktop apps
Desktop Packaging
Package and distribute desktop apps (DMG, MSI, AppImage)
Want a Desktop Apps skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.