Electron Desktop App

This project can be run as a desktop application using Electron. The entire Next.js app (UI + API routes) is bundled into a cross-platform desktop executable.

Architecture

Development

Prerequisites

Running in Development Mode

# Start Next.js dev server + Electron window
bun run electron:dev

This command:

  1. Starts Next.js dev server on port 3000
  2. Waits for the server to be ready
  3. Opens Electron window pointing to localhost:3000
  4. Includes hot reload for frontend changes

Building for Production

# Build Next.js and package Electron app for your current platform
bun run electron:build

This will:

  1. Build Next.js in standalone mode
  2. Copy static files and public assets
  3. Package the app using electron-builder
  4. Output to dist/ directory

Platform-Specific Builds

# macOS (creates .dmg)
bunx electron-builder --mac

# Windows (creates .exe installer)
bunx electron-builder --win

# Linux (creates .AppImage and .deb)
bunx electron-builder --linux

GitHub Actions CI/CD

The project includes automated builds via GitHub Actions:

Triggers

Build Matrix

Builds are created for:

Releases

When you push a version tag (e.g., v1.0.0):

  1. GitHub Actions builds for all platforms
  2. Creates a draft release
  3. Uploads installers as release assets
  4. Generates release notes automatically

To create a release:

git tag v1.0.0
git push origin v1.0.0

Configuration

electron-builder

Configuration is in package.json under the build key:

Electron Main Process

File: electron/main.js

Next.js Config

File: next.config.js

Bundle Size

Expected app sizes:

Size includes:

Security

The Electron app includes security measures:

Troubleshooting

Development Issues

Electron window is blank:

Hot reload not working:

Build Issues

Build fails with "Cannot find module":

App crashes on startup:

Development Workflow

  1. Web Development: Use bun next:dev for standard Next.js development
  2. Desktop Testing: Use bun run electron:dev to test in Electron
  3. CLI Testing: Use existing bun book commands for CLI functionality
  4. Production Build: Use bun run electron:build before releasing

Future Enhancements

Potential improvements: