Skip to content

pnstack/template-electron

Repository files navigation

Template Electron

CI Release Code Quality License: MIT

A modern, production-ready Electron application template built with TypeScript, React, and TailwindCSS.

πŸš€ Features

  • ⚑ 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

πŸ“‹ Prerequisites

  • Node.js 18+ and npm

πŸ› οΈ Installation

# Clone the repository
git clone https://github.com/pnstack/template-electron.git

# Navigate to the project directory
cd template-electron

# Install dependencies
npm install

πŸ’» Development

# Start the development server
npm run dev

This will start the Vite dev server and launch the Electron application with hot-reload enabled.

πŸ—οΈ Building

# 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  # Linux

The packaged application will be in the release directory.

πŸ“ Project Structure

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

πŸ”§ Configuration

Vite

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

Electron

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

Tailwind CSS

Configure Tailwind by editing tailwind.config.js. The template includes:

  • Configured content paths for tree-shaking
  • Ready for custom themes and plugins

πŸ”’ Security

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

πŸ”„ CI/CD

This project includes comprehensive CI/CD workflows using GitHub Actions:

Workflows

  • 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
  • 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

Creating a Release

To create a new release:

# Create and push a version tag
git tag v1.0.0
git push origin v1.0.0

The release workflow will automatically build and publish binaries for all platforms.

Dependencies

Dependabot is configured to automatically check for:

  • npm package updates (weekly)
  • GitHub Actions updates (weekly)

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - feel free to use this template for any project!

πŸ™ Acknowledgments

Built with:

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •