A streamlined template for creating cross-platform applications using React + Capacitor + Electron.
CapViteTron is a clean, generalized template that allows you to:
- Write one React codebase
- Build for multiple platforms: Web, Desktop (Windows/macOS/Linux), and Mobile (Android/iOS)
- Use modern development tools: TypeScript, Vite, ESLint
- Deploy easily with automated build scripts
- YomiHelper β https://github.com/riozee/yomihelper
# Install dependencies
npm install
# Start development server
npm run dev
# Build for all platforms
npm run build:cleanThis repository includes a PowerShell script to help you scaffold a new project from this template. The new-project.ps1 script will copy the template files, update the project name, app ID, and author in the configuration files.
To create a new project, run the following command in your terminal:
.\scripts\new-project.ps1 -ProjectName "MyNewApp" -AppId "com.example.mynewapp"Parameters:
-ProjectName(Required): The name of your new project.-AppId(Required): The application ID for your project (e.g.,com.company.appname).-Author(Optional): The author's name. Defaults to "riozee".-Destination(Optional): The directory where the new project will be created. Defaults to the current directory.
- Node.js 18+
- npm or yarn
- Java JDK 21 (Download) - Required for Android builds
- Android Studio with Android SDK
- No additional requirements (Electron handles this)
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build React app only |
npm run build:all |
Build for all platforms |
npm run build:android |
Build Android APK |
npm run build:desktop |
Build desktop app |
npm run clean |
Clean all build artifacts |
npm run sync |
Sync Capacitor platforms |
.\scripts\build.ps1 |
Cross-platform build script |
.\scripts\organize-output.ps1 |
Organize builds in output/ folder |
.\scripts\find-java.ps1 |
Check Java installation for Android |
capvitetron/
βββ src/ # React source code
β βββ App.tsx # Main app component
β βββ main.tsx # React entry point
β βββ ...
βββ electron/ # Electron main process
β βββ main.js # Electron configuration
βββ scripts/ # Build and utility scripts
β βββ build.ps1 # Cross-platform build script
β βββ find-java.ps1 # Java detection for Android
β βββ setup.js # Post-install setup
βββ public/ # Static assets
βββ output/ # Built applications (created after build)
βββ android/ # Android platform (created by Capacitor)
- Progressive Web App capabilities
- Hot module replacement during development
- Modern browser features
- Native desktop application
- Cross-platform (Windows, macOS, Linux)
- Native OS integration
- Native Android APK
- Access to device APIs
- App store distribution ready
Edit capacitor.config.ts to change:
- App ID and name
- Platform-specific settings
- Plugin configurations
Edit electron/main.js to modify:
- Window properties
- Security settings
- Native integrations
Edit package.json build section for:
- Output formats
- Signing certificates
- Distribution settings
# Check Java version and installation
.\scripts\find-java.ps1
# Install Java 21 if missing
choco install temurin21
# Manually set Java 21 if multiple versions exist
$env:JAVA_HOME = "C:\Program Files\Eclipse Adoptium\jdk-21.0.x"
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"# Clean all builds and retry
npm run clean
.\scripts\build.ps1
# Organize existing builds
.\scripts\organize-output.ps1# Check if port 5173 is available
npm run devAfter building, find your apps in the output/ folder:
- Desktop:
*.exe(Windows),*.AppImage(Linux),*.dmg(macOS) - Android:
app-debug.apkorapp-release.apk
This is a template project. To customize for your needs:
- Fork or clone this template
- Update app name, ID, and branding
- Add your application logic
- Customize build configurations
- Add platform-specific features
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding! π