This guide explains how to turn your Vite/React app into a Linux desktop application, packaged as a .deb (Debian/Ubuntu) and an AppImage (portable Linux app). The recommended approach is to use Electron and electron-builder.
- Node.js and npm installed
- Your Vite/React app builds successfully (
npm run build) - Linux system or WSL/VM for building
-
Build your Vite app:
npm run build
This creates a
distfolder with your static files. -
Install Electron and electron-builder:
npm install --save-dev electron electron-builder
-
Create an Electron main process file (
main.js):const { app, BrowserWindow } = require('electron'); const path = require('path'); function createWindow() { const win = new BrowserWindow({ width: 1200, height: 800, webPreferences: { nodeIntegration: false, contextIsolation: true, }, }); win.loadFile(path.join(__dirname, 'dist/index.html')); } app.whenReady().then(createWindow); app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
-
Update your
package.json: Add or update these fields:"main": "main.js", "build": { "appId": "com.example.quadparts", "productName": "QuadParts", "files": [ "dist/**/*", "main.js" ], "linux": { "target": ["deb", "AppImage"], "category": "Utility" } }, "scripts": { "electron": "electron .", "electron:build": "electron-builder --linux" }
Run:
npm run electron:build- This will generate
.deband.AppImagefiles in thedist/ordist_electron/directory.
- Test the generated files on a Linux system.
.debcan be installed on Debian/Ubuntu with:sudo dpkg -i QuadParts*.deb.AppImageis portable; make it executable and run:chmod +x QuadParts*.AppImage ./QuadParts*.AppImage
- You can customize icons, metadata, and more in the
buildsection ofpackage.json. - For advanced options, see the electron-builder Linux docs.
- You can also build on Windows/macOS, but cross-compiling for Linux may require extra setup (see electron-builder docs).