Skip to main content
FarmFarm
Version: 2.x (Latest)
On this page

Electron

Create a Electron project based on Farm.

Farm provides two approaches to support creating Electron projects:

  • Use the create-farm scaffold to create a scaffold project
  • You can manually create a Electron project following the current documentation

Creating a Electron Project

sh
npm create farm@latest
sh
yarn create farm@latest
sh
pnpm create farm@latest
sh
bun create farm@latest

Select Electron template in Select Framework

After selecting Electron, you can continue to select all sub templates already supported by Farm

ts
- React
- Vue
- Preact
- Svelte
- Solid

You can choose the framework you want to use to run on electron, farm wrote electron js plugin

such as react template

ts
import { defineConfig } from '@farmfe/core';
import react from '@farmfe/plugin-react';
import electron from '@farmfe/js-plugin-electron';

export default defineConfig({
  plugins: [
    react(),
    electron({
      main: {
        input: 'electron/main.ts',
      },
      preload: {
        input: 'electron/preload.ts',
      },
    }),
  ]
});

For more example details: Electron Example

100%

Drag or pinch to explore. Keyboard: + / − zoom, arrows pan, 0 resets, Esc closes.