A modern, production-ready Electron application template built with TypeScript, React, and TailwindCSS.
- β‘ Vite - Lightning fast HMR and build tool
- βοΈ React 19 - Latest React with hooks
- π· TypeScript - Type safety and better DX
- π¨ Tailwind CSS - Utility-first CSS framework
- π¦ Electron Builder - Package and distribute your app
- π Secure - Context isolation and secure IPC
- Node.js 18+ and npm
# Clone the repository
git clone https://github.com/pnstack/template-electron.git
# Navigate to the project directory
cd template-electron
# Install dependencies
npm install# Start the development server
npm run devThis will start the Vite dev server and launch the Electron application with hot-reload enabled.
# Build for production
npm run build
# Build and package for your current platform
npm run electron:build
# Build for specific platforms
npm run electron:build:win # Windows
npm run electron:build:mac # macOS
npm run electron:build:linux # LinuxThe packaged application will be in the release directory.
template-electron/
βββ src/
β βββ main/ # Electron main process
β β βββ main.ts # Main process entry
β βββ preload/ # Preload scripts
β β βββ preload.ts # Secure IPC bridge
β βββ renderer/ # React application
β βββ App.tsx # Main React component
β βββ main.tsx # React entry point
β βββ index.css # Tailwind directives
β βββ electron.d.ts # TypeScript definitions
βββ index.html # HTML template
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # Tailwind configuration
βββ tsconfig.json # TypeScript config (renderer)
βββ tsconfig.node.json # TypeScript config (main/preload)
βββ package.json # Project dependencies
The Vite configuration (vite.config.ts) includes:
- React plugin for JSX/TSX support
- Electron plugin for main and preload scripts
- Path aliases for cleaner imports
The main process (src/main/main.ts) creates the browser window and handles:
- Window creation and management
- Loading the renderer in dev/prod mode
- IPC communication with renderer
Configure Tailwind by editing tailwind.config.js. The template includes:
- Configured content paths for tree-shaking
- Ready for custom themes and plugins
This template follows Electron security best practices:
- Context isolation enabled
- Node integration disabled
- Secure IPC via preload script
- No direct Node.js access in renderer
This project includes comprehensive CI/CD workflows using GitHub Actions:
-
CI (
ci.yml) - Runs on every push and PR- Tests across multiple OS (Ubuntu, Windows, macOS)
- Tests across multiple Node.js versions (18.x, 20.x)
- Type checking with TypeScript
- Build verification
- Automatic artifact uploads
-
Release (
release.yml) - Automated releases- Triggers on version tags (e.g.,
v1.0.0) - Builds for all platforms (Windows, macOS, Linux)
- Creates GitHub releases with binaries
- Manual trigger option available
- Triggers on version tags (e.g.,
-
PR Check (
pr-check.yml) - Pull request validation- Type checking
- Build verification
- PR size warnings
-
Code Quality (
quality.yml) - Code quality checks- TypeScript validation
- Security audits
- Bundle size analysis
- Weekly scheduled runs
To create a new release:
# Create and push a version tag
git tag v1.0.0
git push origin v1.0.0The release workflow will automatically build and publish binaries for all platforms.
Dependabot is configured to automatically check for:
- npm package updates (weekly)
- GitHub Actions updates (weekly)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this template for any project!
Built with: