Co-authored-by: mileswolfallen2 <[email protected]>
3.6 KiB
Gelectron
Run Electron-style apps on native OS web views with a Rust runtime and a JavaScript compatibility layer.
Gelectron is an Electron alternative focused on using platform-native web views through wry and tao, plus a Node-compatible API shim.
Project status
- Early-stage project under active development
- Compatibility is partial and evolving
- Some Electron APIs are implemented, others are stubs or no-ops
If you are evaluating migration from Electron, test your app against Gelectron directly before committing to it.
Install
The npm package exposes:
gelectrongelectron-coregelectron-packager
npm install -g gelectron-core
Quick start
Run an app directory (uses package.json -> main):
gelectron /path/to/electron-app
gelectron .
Run a main-process script directly:
gelectron main.js
Show CLI version/help:
gelectron --version
gelectron --help
If the native runtime binary is unavailable, the CLI falls back to the Node.js compatibility runtime (src/electron/runtime.js), which is API-only and does not provide a native desktop window.
Build from source
Prerequisites
- Rust (stable)
- Node.js 18+
- npm
Build and run
git clone https://github.com/mileswolfallen2/gelectron.git
cd gelectron
npm install
# Build native runtime binary
cargo build --release -p gelectron
# Run demo app
cargo run --release -p gelectron -- demo/
Architecture (high level)
Gelectron is composed of:
-
Rust runtime (
crates/gelectron-app)- Native app process
- Window/event loop via
tao - Native web view via
wry
-
JS compatibility layer (
src/electron/)require('electron')-style API surface- Main-process and renderer shims
- IPC bridge to the native runtime
-
CLI launcher (
cli/gelectron.js)- Resolves app entry point
- Locates and launches the native runtime when present
- Falls back to JS runtime when native binary is not found
API compatibility
Gelectron exposes Electron-like modules from src/electron/index.js, including:
appBrowserWindowipcMainMenu/MenuItemTraydialogshellNotificationnativeImagesafeStoragecontextBridgewebContentsautoUpdaterclipboardscreennativeThemesession(stubbed behavior)- plus additional stubs such as
systemPreferences,powerMonitor, andglobalShortcut
Because behavior is still maturing, treat compatibility as best-effort rather than complete parity.
Packaging
gelectron-packager is included as a CLI tool:
gelectron-packager --dir ./demo --name MyApp
You can also specify target platform/arch:
gelectron-packager --dir ./my-app --name MyApp --platform darwin --arch arm64
gelectron-packager --dir ./my-app --name MyApp --platform win32 --arch x64
gelectron-packager --dir ./my-app --name MyApp --platform linux --arch x64
Repository layout
gelectron/
├── cli/ # CLI entrypoint
├── src/electron/ # Electron compatibility layer
├── crates/gelectron-app/ # Rust native runtime binary
├── crates/gelectron-core/ # Rust native core (N-API related)
├── packager/ # gelectron-packager
├── demo/ # Example app
└── npm/ # Platform npm package assets
Contributing
See CONTRIBUTING.md.