A modern Electron application template with React, Vite, TypeScript, and TailwindCSS. This project provides a solid foundation for developing cross-platform desktop applications.
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:
The titlebar menu can be toggled using:
Alt
keyOption (ā„)
keyWhen you press the toggle key:
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