electrobun-best-practices

Guides building Electrobun desktop apps with typed RPC, secure webviews, and distribution workflows.

1|2|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/Odonno/cleanmail --skill electrobun-best-practices-odonno
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: electrobun-best-practices
Source: https://github.com/Odonno/cleanmail/tree/main/.agents/skills/electrobun-best-practices
Command: npx skills add https://github.com/Odonno/cleanmail --skill electrobun-best-practices-odonno

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building cross-platform desktop apps with Electrobun involves fast-evolving APIs, split Bun/browser contexts, and tricky build, update, and distribution steps. This Skill provides safe defaults, typed RPC patterns, and operational guidance so you avoid common pitfalls like broken RPC in sandboxed webviews, misconfigured navigation rules, and updater channel mismatches. ## Core Features & Use Cases - Typed RPC Patterns: Define shared RPCSchema types between the Bun main process and browser views, with request/message handlers on both sides. - Security Baselines: Apply sandbox mode, navigation allowlists, and per-account partitions for untrusted or multi-account content. - Build & Distribution Guidance: Configure electrobun.config.ts, build lifecycle hooks, updater flows, and channel-based artifacts (canary/stable). - Use Case: You are building a desktop mail client with Electrobun and need to isolate multiple IMAP account sessions, render remote HTML safely in sandboxed webviews, and ship auto-updates through a stable release channel. ## Quick Start Ask the assistant to scaffold an Electrobun app with a typed RPC layer between the Bun main process and a sandboxed BrowserWindow, following Electrobun best practices.

Frequently Asked Questions about electrobun-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up typed RPC between Bun and browser in Electrobun?

Define a shared RPCSchema type with requests and messages for both bun and webview sides, then call BrowserView.defineRPC in the main process and Electroview.defineRPC in the browser. Both sides must implement matching handlers for the shared types.

How do I secure an Electrobun BrowserWindow loading untrusted content?

Set sandbox: true on the BrowserWindow, which disables RPC while keeping events working. Add strict navigation allowlists with setNavigationRules, use a separate partition for isolation, and validate all host-message payloads from preload scripts.

Why do Electrobun RPC calls fail in my webview?

RPC fails when the target webview is sandboxed, since sandbox: true disables RPC entirely. Also confirm that the shared RPC types match the handlers registered on both the bun and browser sides.

How does the Electrobun updater work with release channels?

Build with --env=canary or --env=stable to produce artifacts named by channel, os, and arch, then upload the artifacts folder to your release.baseUrl. The updater tries incremental patches first and falls back to a full bundle download.

Does Electrobun support multi-account session isolation?

Yes, use explicit partition values per account when creating windows or webviews, and manage cookies through Session.fromPartition. This prevents session and storage leakage between accounts.

Why is before-quit not firing on Linux in Electrobun?

Some system-initiated quit paths on Linux, such as Ctrl+C or window-manager quit, may not fire before-quit. Programmatic quit via Utils.quit() or process.exit() reliably triggers the shutdown lifecycle.