{"id":20766211,"url":"https://github.com/navono/electron-template","last_synced_at":"2026-04-28T03:33:53.314Z","repository":{"id":186283593,"uuid":"674532525","full_name":"navono/electron-template","owner":"navono","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-04T07:10:10.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T12:22:55.308Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/navono.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"custom":["https://www.buymeacoffee.com/kozack/","https://send.monobank.ua/6SmojkkR9i"]}},"created_at":"2023-08-04T07:10:07.000Z","updated_at":"2023-08-04T07:10:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"376d0c3f-da20-4e80-9636-0a748456e73c","html_url":"https://github.com/navono/electron-template","commit_stats":null,"previous_names":["navono/electron-template"],"tags_count":0,"template":false,"template_full_name":"cawa-93/vite-electron-builder","purl":"pkg:github/navono/electron-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Felectron-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Felectron-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Felectron-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Felectron-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/navono","download_url":"https://codeload.github.com/navono/electron-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Felectron-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32365509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T11:22:01.636Z","updated_at":"2026-04-28T03:33:53.299Z","avatar_url":"https://github.com/navono.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/kozack/","https://send.monobank.ua/6SmojkkR9i","https://www.buymeacoffee.com/kozack/)!","https://www.patreon.com/Kozack/"],"categories":[],"sub_categories":[],"readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)\n\n---\n\n# Vite Electron Builder Boilerplate\n\nThis is a template for secure electron applications. Written following the latest safety requirements, recommendations\nand best practices.\n\nUnder the hood is [Vite] — A next-generation blazing fast bundler, and [electron-builder] for packaging.\n\n## Get started\n\nFollow these steps to get started with the template:\n\n1. Click the **[Use this template](https://github.com/cawa-93/vite-electron-builder/generate)** button (you must be\n   logged in) or just clone this repo.\n2. If you want to use another package manager you may need to edit [`.github/workflows`](https://github.com/search?q=npm+repo%3Acawa-93%2Fvite-electron-builder+path%3A.github%2Fworkflows\u0026type=Code) since npm is used as default. (See also https://github.com/cawa-93/vite-electron-builder/issues/944)\n   \u003e **Note**:\n   \u003e This template configured to install `peerDependencies` automatically.\n\n\nThat's all you need. 😉\n\n❤️ **If you like this template, don't forget to give a ⭐ or [send support](https://www.buymeacoffee.com/kozack/)!** \n\n\n## Features\n\n### Electron [![Electron version](https://img.shields.io/github/package-json/dependency-version/cawa-93/vite-electron-builder/dev/electron?label=%20)][electron]\n\n- This template uses the latest electron version with all the latest security patches.\n- The architecture of the application is built according to the\n  security [guides](https://www.electronjs.org/docs/tutorial/security) and best practices.\n- The latest version of the [electron-builder] is used to package the application.\n\n### Vite [![Vite version](https://img.shields.io/github/package-json/dependency-version/cawa-93/vite-electron-builder/dev/vite?label=%20)][vite]\n\n- [Vite] is used to bundle all source codes. It's an extremely fast bundler, that has a vast array of amazing features.\n  You can learn more about how it is arranged in [this](https://www.youtube.com/watch?v=xXrhg26VCSc) video.\n- Vite [supports](https://vitejs.dev/guide/env-and-mode.html) reading `.env` files. You can also specify the types of\n  your environment variables in [`types/env.d.ts`](types/env.d.ts).\n- Automatic hot-reloads for the `Main` and `Renderer` processes.\n\nVite provides many useful features, such as: `TypeScript`, `TSX/JSX`, `CSS/JSON Importing`, `CSS Modules`\n, `Web Assembly` and much more.\n\n\u003e [See all Vite features](https://vitejs.dev/guide/features.html).\n\n### TypeScript [![TypeScript version](https://img.shields.io/github/package-json/dependency-version/cawa-93/vite-electron-builder/dev/typescript?label=%20)][typescript] (optional)\n\n- The latest version of TypeScript is used for all the source code.\n- **Vite** supports TypeScript out of the box. However, it does not support type checking.\n- Code formatting rules follow the latest TypeScript recommendations and best practices thanks\n  to [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin).\n\n\u003e [Guide to disable typescript and remove dependencies](https://github.com/cawa-93/vite-electron-builder/discussions/339) \n\n### Vue [![Vue version](https://img.shields.io/github/package-json/dependency-version/cawa-93/vite-electron-builder/dev/vue?label=%20\u0026)][vue] (optional)\n\n- By default, web pages are built using [Vue]. However, you can easily change that. Or not use additional frameworks at\n  all.\n- Code formatting rules follow the latest Vue recommendations and best practices thanks to [eslint-plugin-vue].\n\n\u003e [Find more forks 🔱 for others frameworks or setups](https://github.com/cawa-93/vite-electron-builder/discussions/categories/forks)\n\n### Continuous Integration\n\n- The configured workflow will check the types for each push and PR.\n- The configured workflow will check the code style for each push and PR.\n- **Automatic tests**\n  used [Vitest ![Vitest version](https://img.shields.io/github/package-json/dependency-version/cawa-93/vite-electron-builder/dev/vitest?label=%20\u0026color=yellow)][vitest]\n  -- A blazing fast test framework powered by Vite.\n  - Unit tests are placed within each package and are ran separately.\n  - End-to-end tests are placed in the root [`tests`](tests) directory and use [playwright].\n\n![Workflow graph](https://user-images.githubusercontent.com/1662812/213429323-ef4bcc87-c273-4f2f-b77f-c04cf6dbc36d.png)\n\n\n### Publishing\n\n- Each time you push changes to the `main` branch, the [`release`](.github/workflows/release.yml) workflow starts, which creates a new draft release. For each next commit will be created and replaced artifacts. That way you will always have draft with latest artifacts, and the release can be published once it is ready. \n  - Code signing supported. See [`release` workflow](.github/workflows/release.yml).\n  - **Auto-update is supported**. After the release is published, all client applications will download the new version\n  and install updates silently.\n  \n\u003e **Note**:\n\u003e This template **configured only for GitHub public repository**, but electron-builder also supports other update distribution servers. Find more in [electron-builder docs](https://www.electron.build/configuration/publish).\n\n## How it works\n\nThe template requires a minimum amount [dependencies](package.json). Only **Vite** is used for building, nothing more.\n\n### Project Structure\n\nThe structure of this template is very similar to a monorepo. The entire source code of the project is divided into three modules (packages) that are each bundled independently:\n\n- [`packages/renderer`](packages/renderer). Responsible for the contents of the application window. In fact, it is a\n  regular web application. In developer mode, you can even open it in a browser. The development and build process is\n  the same as for classic web applications. Access to low-level API electrons or Node.js is done through the _preload_\n  layer.\n- [`packages/preload`](packages/preload). Contain Electron [**preload scripts**](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload). Acts as an intermediate bridge between the _renderer_ process and the API\n  exposed by electron and Node.js. Runs in an _isolated browser context_, but has direct access to the full Node.js\n  functionality.\n- [`packages/main`](packages/main)\n  Contain Electron [**main script**](https://www.electronjs.org/docs/tutorial/quick-start#create-the-main-script-file). This is\n  the main process that powers the application. It manages creating and handling the spawned BrowserWindow, setting and\n  enforcing secure permissions and request handlers. You can also configure it to do much more as per your need, such\n  as: logging, reporting statistics and health status among others.\n\nSchematically, the structure of the application and the method of communication between packages can be depicted as follows:\n```mermaid\nflowchart TB;\n\npackages/preload \u003c-. IPC Messages .-\u003e packages/main\n\n    subgraph packages/main[\"packages/main (Shared beatween all windows)\"]\n    M[index.ts] --\u003e EM[Electron Main Process Modules]\n    M --\u003e N2[Node.js API]\n    end\n\nsubgraph Window[\"Browser Window\"]\n    subgraph packages/preload[\"packages/preload (Works in isolated context)\"]\n    P[index.ts] --\u003e N[Node.js API]\n    P --\u003e ED[External dependencies]\n    P --\u003e ER[Electron Renderer Process Modules]\n    end\n\n\n    subgraph packages/renderer\n    R[index.html] --\u003e W[Web API]\n    R --\u003e BD[Bundled dependencies]\n    R --\u003e F[Web Frameforks]\n    end\n    end\n\npackages/renderer -- Call Exposed API --\u003e P\n```\n### Build web resources\n\nThe `main` and `preload` packages are built in [library mode](https://vitejs.dev/guide/build.html#library-mode) as it is\nsimple javascript.\nThe `renderer` package builds as a regular web app.\n\n### Compile App\n\nThe next step is to package a ready to distribute Electron app for macOS, Windows and Linux with \"auto update\" support\nout of the box.\n\nTo do this, use [electron-builder]:\n\n- Using the npm script `compile`: This script is configured to compile the application as quickly as possible. It is not\n  ready for distribution, it is compiled only for the current platform and is used for debugging.\n- Using GitHub Actions: The application is compiled for any platform and ready-to-distribute files are automatically\n  added as a draft to the GitHub releases page.\n\n### Working with dependencies\n\nBecause the `renderer` works and builds like a _regular web application_, you can only use dependencies that support the\nbrowser or compile to a browser-friendly format.\n\nThis means that in the `renderer` you are free to use any frontend dependencies such as Vue, React, lodash, axios and so\non. However, you _CANNOT_ use any native Node.js APIs, such as, `systeminformation`. These APIs are _only_ available in\na Node.js runtime environment and will cause your application to crash if used in the `renderer` layer. Instead, if you\nneed access to Node.js runtime APIs in your frontend, export a function form the `preload` package.\n\nAll dependencies that require Node.js api can be used in\nthe [`preload` script](https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts).\n\n#### Expose in main world\nHere is an example. Let's say you need to read some data from the file system or database in the renderer.\n\nIn the preload context, create a function that reads and returns data. To make the function announced in the preload\navailable in the render, you usually need to call\nthe [`electron.contextBridge.exposeInMainWorld`](https://www.electronjs.org/ru/docs/latest/api/context-bridge). However,\nthis template uses the [unplugin-auto-expose](https://github.com/cawa-93/unplugin-auto-expose) plugin, so you just need\nto export the method from the preload. The `exposeInMainWorld` will be called automatically.\n\n```ts\n// preload/index.ts\nimport { readFile } from 'node:fs/promises';\n\n// Encapsulate types if you use typescript\ninterface UserData {\n  prop: string\n}\n\n// Encapsulate all node.js api\n// Everything you exported from preload/index.ts may be called in renderer\nexport function getUserData(): Promise\u003cUserData\u003e {\n  return readFile('/path/to/file/in/user/filesystem.json', {encoding:'utf8'}).then(JSON.parse);\n}\n```\n\nNow you can import and call the method in renderer\n\n```ts\n// renderer/anywere/component.ts\nimport { getUserData } from '#preload'\nconst userData = await getUserData()\n```\n\n\u003e Find more in [Context Isolation tutorial](https://www.electronjs.org/docs/tutorial/context-isolation#security-considerations).\n\n### Working with Electron API\n\nAlthough the preload has access to all of Node.js's API, it **still runs in the BrowserWindow context**, so a limited\nelectron modules are available in it. Check the [electron docs](https://www.electronjs.org/ru/docs/latest/api/clipboard)\nfor full list of available methods.\n\nAll other electron methods can be invoked in the `main`.\n\nAs a result, the architecture of interaction between all modules is as follows:\n\n```mermaid\nsequenceDiagram\nrenderer-\u003e\u003e+preload: Read data from file system\npreload-\u003e\u003e-renderer: Data\nrenderer-\u003e\u003epreload: Maximize window\nactivate preload\npreload--\u003e\u003emain: Invoke IPC command\nactivate main\nmain--\u003e\u003epreload: IPC response\ndeactivate main\npreload-\u003e\u003erenderer: Window maximized\ndeactivate preload\n```\n\n\u003e Find more in [Inter-Process Communication tutorial](https://www.electronjs.org/docs/latest/tutorial/ipc).\n\n### Modes and Environment Variables\n\nAll environment variables are set as part of the `import.meta`, so you can access them vie the following\nway: `import.meta.env`.\n\n\u003e **Note**:\n\u003e If you are using TypeScript and want to get code completion you must add all the environment variables to\nthe [`ImportMetaEnv` in `types/env.d.ts`](types/env.d.ts).\n\nThe mode option is used to specify the value of `import.meta.env.MODE` and the corresponding environment variables files\nthat need to be loaded.\n\nBy default, there are two modes:\n\n- `production` is used by default\n- `development` is used by `npm run watch` script\n\nWhen running the build script, the environment variables are loaded from the following files in your project root:\n\n```\n.env                # loaded in all cases\n.env.local          # loaded in all cases, ignored by git\n.env.[mode]         # only loaded in specified env mode\n.env.[mode].local   # only loaded in specified env mode, ignored by git\n```\n\n\u003e **Warning**: \n\u003e To prevent accidentally leaking env variables to the client, only variables prefixed with `VITE_` are exposed to your\nVite-processed code.\n\nFor example let's take the following `.env` file:\n\n```\nDB_PASSWORD=foobar\nVITE_SOME_KEY=123\n```\n\nOnly `VITE_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your client source code, but `DB_PASSWORD`\nwill not.\n\nYou can change that prefix or add another. See [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix)\n\n## Contribution\n\nSee [Contributing Guide](contributing.md).\n\n\n[vite]: https://github.com/vitejs/vite/\n\n[electron]: https://github.com/electron/electron\n\n[electron-builder]: https://github.com/electron-userland/electron-builder\n\n[vue]: https://github.com/vuejs/vue-next\n\n[vue-router]: https://github.com/vuejs/vue-router-next/\n\n[typescript]: https://github.com/microsoft/TypeScript/\n\n[playwright]: https://playwright.dev\n\n[vitest]: https://vitest.dev\n\n[vue-tsc]: https://github.com/johnsoncodehk/vue-tsc\n\n[eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue\n\n[cawa-93-github]: https://github.com/cawa-93/\n\n[cawa-93-sponsor]: https://www.patreon.com/Kozack/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavono%2Felectron-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnavono%2Felectron-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavono%2Felectron-template/lists"}