A modern, secure, and feature-rich Electron + React starter template with best practices built-in.
- Modern Stack: Electron 37+ with React 19
- Security First: Context isolation, disabled node integration, CSP headers
- Development Experience: Hot reload, dev tools, source maps
- Build System: Webpack 5 with Babel transpilation
- Testing: Jest setup with example tests
- Cross-Platform: Windows, macOS, and Linux support
- Modern UI: Beautiful gradient design with responsive layout
- ✅ Secure IPC communication between main and renderer processes
- ✅ Modern React with hooks and error boundaries
- ✅ Webpack configuration for development and production
- ✅ Hot reload during development
- ✅ Professional application menu
- ✅ CSS modules support
- ✅ Jest testing framework
- ✅ Cross-platform build configuration
- ✅ Security best practices implemented
# Clone the repository
git clone https://github.com/codesign-cloud/cdc-electron-starterkit.git
cd cdc-electron-starterkit
# Install dependencies
npm installImportant: You need to build the React app first before running Electron!
# This automatically builds the React app AND starts Electron with hot reload
npm start# Step 1: Build the React app first
npm run build:renderer:dev
# Step 2: Then start Electron
npm run start:electron# Build renderer for development (with source maps) - REQUIRED before first run
npm run build:renderer:dev
# Build renderer for production (optimized)
npm run build:renderer
# Clean build artifacts
npm run cleanNote: The npm start command runs both webpack (to build React) and Electron simultaneously with hot reload, so you don't need to build separately when using it.
# Run tests once
npm test
# Run tests in watch mode
npm run test:watch# Build the app for all platforms
npm run build
# Build and publish (requires proper GitHub setup)
npm run releasecdc-electron-starterkit/
├── src/
│ ├── __tests__/ # Test files
│ ├── main.js # Electron main process
│ ├── preload.js # Secure bridge script
│ ├── renderer.jsx # React application
│ ├── index.html # HTML template
│ └── style.css # Application styles
├── dist/ # Built files (auto-generated)
├── docs/ # Documentation
├── package.json # Dependencies and scripts
├── webpack.config.js # Webpack configuration
├── babel.config.js # Babel configuration
└── jest.config.js # Jest configuration
src/
├── renderer.jsx ← Main React app (edit here!)
├── style.css ← Styling (edit here!)
├── index.html ← HTML template
├── main.js ← Electron main process
└── preload.js ← Security bridge
This starterkit implements Electron security best practices:
- Context Isolation: Enabled to prevent renderer access to Node.js APIs
- Node Integration: Disabled in renderer process
- Preload Script: Secure bridge for IPC communication
- Content Security Policy: Configured for development and production
- Sandboxing: Ready to be enabled for additional security
- Menu Security: Prevents unauthorized window creation
- Modify
src/style.cssfor global styles - The app uses a modern gradient design that's fully customizable
- Responsive design works on all screen sizes
- Add new IPC handlers in
src/main.js - Expose them securely through
src/preload.js - Use them in your React components via
window.electronAPI
- Modify
package.jsonbuild section for app metadata - Update
webpack.config.jsfor build customizations - Configure
babel.config.jsfor JavaScript transpilation
| Script | Description |
|---|---|
npm start |
Start development with hot reload |
npm run dev |
Alias for start |
npm test |
Run tests once |
npm run test:watch |
Run tests in watch mode |
npm run build:renderer |
Build renderer for production |
npm run build:renderer:dev |
Build renderer for development |
npm run build |
Build app for all platforms |
npm run release |
Build and publish app |
npm run clean |
Clean build artifacts |
- App won't start: Make sure you've run
npm installandnpm run build:renderer - Hot reload not working: Check that both webpack and electron processes are running
- Build fails: Ensure all dependencies are installed and up to date
- Use
Ctrl+Shift+I(orCmd+Option+Ion Mac) to open DevTools - Check the console for any JavaScript errors
- Use the Network tab to debug resource loading issues
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the CC0-1.0 License - see the LICENSE file for details.
Happy coding! 🎉
