A modern Electron application template with React, Vite, TypeScript, and TailwindCSS. This project provides a solid foundation for developing cross-platform desktop applications.
- π Electron - Cross-platform desktop application framework
- βοΈ React - Component-based UI library
- π¦ TypeScript - Type-safe JavaScript
- π¨ TailwindCSS - Utility-first CSS framework
- β‘ Vite - Lightning-fast build tool
- π₯ Fast HMR - Hot Module Replacement
- π¨ Dark/Light Mode - Built-in theme switching
- πͺ Custom Window & Titlebar - Professional-looking window with custom titlebar & file menus.
- π Clean Project Structure - Separation of main and renderer processes
- 𧩠Path Aliases β Keep your code organized.
- π οΈ Electron Builder - Configured for packaging applications
- Node.js (v18 or higher)
- npm, yarn, pnpm, or bun
Clone the repository and install dependencies:
# Clone the repository
git clone https://github.com/guasam/electron-react-app
cd electron-react-app
# Install dependencies
npm install
# or
yarn
# or
pnpm install
# or
bun install
Start the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun run dev
This will start Electron with hot-reload enabled so you can see changes in real time.
Build the application for your platform:
# For Windows
npm run build:win
# For macOS
npm run build:mac
# For Linux
npm run build:linux
# Unpacked for all platforms
npm run build:unpack
Distribution files will be located in the dist
directory.
The app uses a secure IPC (Inter-Process Communication) system to communicate between the renderer and main processes:
// Renderer process (send message to main)
window.api.send('channel-name', ...args)
// Renderer process (receive message from main)
window.api.receive('channel-name', (data) => {
console.log(data)
})
// Renderer process (invoke a method in main and get a response)
const result = await window.api.invoke('channel-name', ...args)
This template includes a custom window implementation with:
- Custom titlebar with app icon
- Window control buttons (minimize, maximize, close)
- Menu system with keyboard shortcuts
- Dark/light mode toggle
- Cross-platform support for Windows and macOS
The titlebar menu can be toggled using:
- Windows: Press the
Alt
key - macOS: Press the
Option (β₯)
key
When you press the toggle key:
- If the menu is hidden, it becomes visible
- If the menu is already visible, it gets hidden
- The menu only toggles if menu items are available
To add, remove or modify menu items, update the lib/window/titlebarMenus.ts
file.
The project supports TailwindCSS for styling:
// Example component with Tailwind classes
const Button = () => (
<button className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
Click me
</button>
);
Contributions are welcome! Feel free to submit a Pull Request.
βββ app/ # Renderer process files
β βββ assets/ # Static assets (images, fonts, etc)
β βββ components/ # React components
β β βββ App.tsx # Application component
β βββ styles/ # CSS and Tailwind files
β β βββ app.css # App stylesheet
β β βββ tailwind.css # Tailwind stylesheet
β βββ index.html # Entry HTML file
β βββ renderer.tsx # Renderer process entry
βββ lib/ # Shared library code
β βββ main/ # Main process code
β β βββ index.ts # Main entry point for Electron
β β βββ ... # Other main process modules
β βββ preload/ # Preload scripts for IPC
β β βββ index.ts # Preload script entry
β β βββ api.ts # Exposed API for renderer
β βββ welcome/ # Welcome kit components
β βββ window/ # Custom window implementation
βββ resources/ # Build resources
βββ .eslintrc # ESLint configuration
βββ .prettierrc # Prettier format configuration
βββ electron-builder.yml # Electron builder configuration
βββ electron.vite.config.ts # Vite configuration for Electron
βββ package.json # Project dependencies and scripts
βββ tsconfig.node.json # Main process tsconfig
βββ tsconfig.web.json # Renderer process tsconfig