# electron-vite-react [![awesome-vite](https://awesome.re/mentioned-badge.svg)](https://github.com/vitejs/awesome-vite) ![GitHub stars](https://img.shields.io/github/stars/caoxiemeihao/vite-react-electron?color=fa6470) ![GitHub issues](https://img.shields.io/github/issues/caoxiemeihao/vite-react-electron?color=d8b22d) ![GitHub license](https://img.shields.io/github/license/caoxiemeihao/vite-react-electron) [![Required Node.JS >= 14.18.0 || >=16.0.0](https://img.shields.io/static/v1?label=node&message=14.18.0%20||%20%3E=16.0.0&logo=node.js&color=3f893e)](https://nodejs.org/about/releases) English | [็ฎ€ไฝ“ไธญๆ–‡](README.zh-CN.md) ## ๐Ÿ‘€ Overview ๐Ÿ“ฆ Ready out of the box ๐ŸŽฏ Based on the official [template-react-ts](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts), project structure will be familiar to you ๐ŸŒฑ Easily extendable and customizable ๐Ÿ’ช Supports Node.js API in the renderer process ๐Ÿ”ฉ Supports C/C++ native addons ๐Ÿž Debugger configuration included ๐Ÿ–ฅ Easy to implement multiple windows ## ๐Ÿ›ซ Quick start ```sh npm create electron-vite ``` ![electron-vite-react.gif](/public/electron-vite-react.gif) ## ๐Ÿž Debug ![electron-vite-react-debug.gif](/public/electron-vite-react-debug.gif) ## ๐Ÿ“‚ Directory structure Familiar React application structure, just with `electron` folder on the top :wink: *Files in this folder will be separated from your React application and built into `dist-electron`* ```tree โ”œโ”€โ”€ electron Electron-related code โ”‚ โ”œโ”€โ”€ main Main-process source code โ”‚ โ””โ”€โ”€ preload Preload-scripts source code โ”‚ โ”œโ”€โ”€ release Generated after production build, contains executables โ”‚ โ””โ”€โ”€ {version} โ”‚ โ”œโ”€โ”€ {os}-{os_arch} Contains unpacked application executable โ”‚ โ””โ”€โ”€ {app_name}_{version}.{ext} Installer for the application โ”‚ โ”œโ”€โ”€ public Static assets โ””โ”€โ”€ src Renderer source code, your React application ``` ## ๐Ÿšจ Be aware This template integrates Node.js API to the renderer process by default. If you want to follow **Electron Security Concerns** you might want to disable this feature. You will have to expose needed API by yourself. To get started, remove the option as shown below. This will [modify the Vite configuration and disable this feature](https://github.com/electron-vite/vite-plugin-electron-renderer#config-presets-opinionated). ```diff # vite.config.ts export default { plugins: [ ... - // Use Node.js API in the Renderer-process - renderer({ - nodeIntegration: true, - }), ... ], } ``` ## ๐Ÿ”งAdditional features 1. electron-auto-update([read it docs](src/components/update/README.md)); 1. playwright; ## โ” FAQ - [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies) - [C/C++ addons, Node.js modules - Pre-Bundling](https://github.com/electron-vite/vite-plugin-electron-renderer#dependency-pre-bundling)