Skip to content

XXanderWP/ElectronJS-template

Repository files navigation

ElectronJS-template



A starter template for building desktop applications with Electron, TypeScript, React and Webpack. This repository provides a working example app, build scripts and recommended editor settings for ESLint + Prettier.

Important: This project is intended to be used via GitHub "Use this template" feature (not only cloning).

Features

Project structure

  • src/shared — shared utilities and common code.
  • src/backend — Electron main process, modules, pages and workers.
  • src/frontend — React renderer, entry HTML and styles.
  • src/preload — preload scripts and IPC bridge exposed with contextBridge.
  • src/lang — Language module.
  • src/types — TypeScript global declarations.

Build & output

  • Compiled bundles are emitted to ./dist.
  • Packaged installers/artifacts are produced in ./out by electron-builder.
  • Webpack configs are split for frontend, backend and workers.

NPM scripts

  • npm run watch — run Webpack in watch mode for development.
  • npm run build — build all bundles (Webpack).
  • npm run build:frontend — build frontend bundle only (uses webpack.config.frontend.mjs).
  • npm run build:backend — build backend (main) bundle only (uses webpack.config.backend.mjs).
  • npm run build:workers — build worker bundles only (uses webpack.config.workers.mjs).
  • npm run build:electron — package the app with electron-builder.
  • npm run start — run Electron loading ./dist/main.bundle.js.
  • npm run lint — run ESLint and attempt to fix issues automatically.
  • npm run test — run lint and jest tests.
  • npm run next-patch|next-minor|next-major — bump package version.

How to use this repository as a template

  • On GitHub, press "Use this template" to create a new repository pre-populated with this template.
  • After creating the new repository, update package.json metadata (name, author, productName, appId) and adjust build settings before packaging.

IPC / preload (brief)

  • The preload bridge exposes a small set of safe helpers to the renderer (see src/preload/ipc-api.ts).
  • Renderer code can call window.ipcAPI (types in src/types/global.d.ts).
  • Add main-process handlers under src/backend and expose only safe methods through the preload API.

VSCode, ESLint and Prettier

  • ESLint and Prettier configs are included; run npm run lint to enforce code style.
  • Recommended: install ESLint and Prettier extensions and enable "Format on Save" in VSCode workspace.

Packaging notes

  • Ensure npm run build produces a valid ./dist/main.bundle.js referenced by main in package.json.
  • electron-builder settings live in the build field of package.json.

Contributing / extending

Changelog / Recent notable changes

License

  • MIT — see LICENSE.

Useful files and configs

End of README.

About

A starter template for building desktop applications with ElectronJS

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors