This project is a fully functional macOS desktop application built with Electron that encapsulates a React web application. It includes a bundled Node.js/Express backend, a custom desktop icon setup, and a complete build process for production deployment.
- Desktop Application: A cross-platform desktop app powered by Electron.
- Modern Frontend: A rich, responsive UI built with React, TypeScript, and Tailwind CSS.
- Bundled Backend: A self-contained Node.js/Express server that runs alongside the Electron app.
- Native Integration: Demonstrates Inter-Process Communication (IPC) to call native desktop dialogs from the React app.
- Production Ready: Scripts and configuration for building a distributable macOS
.dmginstaller. - Custom Icon: Setup for including a custom macOS desktop icon (
.icns).
Follow these steps to get the application running on your local machine for development and testing.
- Node.js (v18 or newer recommended)
- npm (comes with Node.js)
-
Clone the repository (if applicable)
git clone <repository-url> cd <project-directory>
-
Install dependencies: This command will install all the necessary dependencies for React, Electron, and the build tools.
npm install
-
Run the development server: This command concurrently starts the Vite dev server for the React app and launches the Electron application. The app will have access to developer tools and hot-reloading for the frontend.
npm run dev
To build the application into a distributable package, follow these steps.
-
Create a custom icon (Optional but Recommended)
- Create a PNG file for your application icon at
assets/icon.png. A resolution of 512x512 or 1024x1024 is recommended. electron-builderwill automatically convert this PNG into a.icnsfile required by macOS during the build process.
- Create a PNG file for your application icon at
-
Run the distribution script: This command first builds the React application for production into the
distfolder, then useselectron-builderto package your app into a macOS.dmginstaller.npm run dist
-
Find the installer: Once the build is complete, you will find the installer file (e.g.,
React Test App-1.0.0.dmg) in therelease/directory.
.
├── assets/
│ └── icon.png # Source for the macOS application icon
├── dist/ # Production build of the React app (generated)
├── release/ # Packaged desktop application (generated)
├── public/
│ └── index.html # HTML template for the React app
├── src/
│ ├── App.tsx # Main React component
│ ├── index.tsx # React entry point
│ └── types.d.ts # TypeScript definitions for window object
├── electron.js # Electron main process entry point
├── preload.js # Electron preload script for IPC
├── server.js # Node.js/Express backend server
├── package.json # Project configuration and scripts
├── README.md # This file
├── tsconfig.json # TypeScript configuration
└── vite.config.ts # Vite build tool configuration