This is a template for building Electron apps using React and Vite. It includes a minimal setup with Tailwind CSS, NextUI, and essential dependencies to get started quickly. Additionally, it includes a basic Express server for API handling.
- ⚡ Electron for building cross-platform desktop applications.
- ⚛️ React with Vite for fast front-end development.
- 🎨 Tailwind CSS for styling.
- 🎭 Framer Motion for animations.
- 🌐 Express server for handling API requests.
- 📦 Electron Builder for packaging the app for Windows, macOS, and Linux.
Ensure you have the following installed:
Clone this repository and install dependencies:
# Clone the repository
git clone https://github.com/rohit-64bit/electron_react_template.git
cd electron_react_template
# Install dependencies
npm installRun the project in development mode:
npm run devThis will start both the React front-end and the Electron main process, including the Express server.
To build the application for production:
npm run buildFor platform-specific builds:
npm run dist:win # Build for WindowsModify the electron-builder.json configuration for custom builds.
├── assets/ # App icons and static files
│ └── logo.png
├── dist/ # Distribution files
│ └── builder-debug.yml
├── src/
│ ├── client-dev/ # React front-end source code
│ │ ├── App.jsx
│ │ ├── index.css
│ │ └── main.jsx
│ ├── electron-dev/ # Electron main process files
│ │ └── main.js # Main process entry (Electron + Express server)
├── .gitignore
├── electron-builder.json # Electron packaging configuration
├── eslint.config.js # ESLint configuration
├── index.html # Main HTML file
├── package-lock.json
├── package.json # Project configuration and scripts
├── postcss.config.js # PostCSS configuration
├── tailwind.config.js # Tailwind CSS configuration
└── vite.config.js # Vite configuration
| Command | Description |
|---|---|
npm run dev |
🚀 Run Electron, React, and Express in development mode |
npm run build |
📦 Build the React front-end |
npm run dist:win |
🏗 Package the app for Windows |
npm run lint |
🔍 Lint the code using ESLint |
npm run preview |
👀 Preview the built React app |
This template includes a basic Express server to handle API requests. It runs on port 8000 and includes a health check endpoint:
GET /healthResponse:
{
"success": true,
"message": "Server is running"
}Modify src/electron-dev/main.js to add more API routes as needed.
This project uses electron-builder to package the application. The configuration supports:
- Windows: Portable and MSI
- macOS: DMG
- Linux: AppImage (Utility category)
Modify electron-builder.json to adjust targets and configurations.
📌 Public Repository: GitHub - Electron React Vite Template