Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
0xbigboss avatar

Electrobun Best Practices

  • 280 installs
  • 52 repo stars
  • Updated June 24, 2026
  • 0xbigboss/claude-code

electrobun-best-practices is a Claude Code agent skill that scaffolds and ships cross-platform desktop applications with Electrobun, Bun bundling, TypeScript layout, native APIs, and secure renderer patterns for develope

About

electrobun-best-practices is a 0xbigboss/claude-code skill guiding agents through Electrobun desktop development with Bun as the main-process runtime and TypeScript across main and renderer layers. Electrobun targets macOS, Windows, and Linux using system webviews—WKWebView, WebView2, and WebKitGTK—instead of bundling Chromium, producing lean binaries often cited around 14MB versus Electron-scale bundles. The skill covers electrobun.config.ts setup, typed RPC between Bun main and webview renderer, BrowserWindow lifecycle, optional CEF bundling on Linux via bundleCEF, and GitHub Actions matrix builds per platform. Reach for electrobun-best-practices when scaffolding a new Electrobun app, hardening renderer security, or preparing cross-platform release artifacts. It suits TypeScript-first developers who want desktop distribution without Rust or a bundled browser engine, accepting per-platform webview rendering differences.

  • Electrobun project scaffolding
  • Bun-native desktop bundling
  • Cross-platform window management
  • Native OS API integration
  • Renderer-main security separation

Electrobun Best Practices by the numbers

  • 280 all-time installs (skills.sh)
  • Ranked #764 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Data as of Jul 30, 2026 (Skillselion catalog sync)
npx skills add https://github.com/0xbigboss/claude-code --skill electrobun-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs280
repo stars52
Last updatedJune 24, 2026
Repository0xbigboss/claude-code

How do you build cross-platform desktop apps with Electrobun?

Scaffold and ship cross-platform desktop apps with Electrobun using Bun bundling, TypeScript layout, native APIs, and secure renderer patterns.

Who is it for?

TypeScript developers shipping small cross-platform desktop apps who want Bun bundling and system webviews instead of Electron's Chromium bundle.

Skip if: Teams needing guaranteed cross-browser rendering parity, a mature plugin ecosystem, or deep native UI without webview layers.

When should I use this skill?

The user asks to scaffold, configure, or ship an Electrobun desktop application with Bun and TypeScript.

What you get

An Electrobun project layout, electrobun.config.ts, typed RPC wiring, and platform build artifacts for macOS, Windows, and Linux.

  • Electrobun project scaffold
  • electrobun.config.ts
  • cross-platform build artifacts

By the numbers

  • Targets 3 desktop platforms: macOS, Windows, and Linux
  • Electrobun apps commonly land around 14MB using system webviews

Files

SKILL.mdMarkdownGitHub ↗

Electrobun Best Practices

Electrobun builds cross-platform desktop apps with TypeScript and Bun. This skill gives safe defaults, typed RPC patterns, and operational guidance for build/update/distribution.

Docs: https://blackboard.sh/electrobun/docs/

Pair with TypeScript Best Practices

Always load typescript-best-practices alongside this skill.

Version and Freshness

Electrobun APIs evolve quickly. Before relying on advanced options or platform-specific behavior, verify against current docs and CLI output.

Architecture

Electrobun apps run as Bun apps:

  • Bun process (main): imports from electrobun/bun
  • Browser context (views): imports from electrobun/view
  • Shared types: RPC schemas shared between both contexts

IPC between bun and browser contexts uses postMessage, FFI, and (in some paths) encrypted WebSockets.

Quick Start

bunx electrobun init
bun install
bun start

Recommended scripts:

{
  "scripts": {
    "start": "electrobun run",
    "dev": "electrobun dev",
    "dev:watch": "electrobun dev --watch",
    "build:dev": "bun install && electrobun build",
    "build:canary": "electrobun build --env=canary",
    "build:stable": "electrobun build --env=stable"
  }
}

Secure Defaults

Use this baseline for untrusted or third-party content:

import { BrowserWindow } from "electrobun/bun";

const win = new BrowserWindow({
  title: "External Content",
  url: "https://example.com",
  sandbox: true,                  // disables RPC, events still work
  partition: "persist:external",
});

win.webview.setNavigationRules([
  "^*",                          // block everything by default
  "*://example.com/*",           // allow only trusted domain(s)
  "^http://*",                   // enforce HTTPS
]);

win.webview.on("will-navigate", (e) => {
  console.log("nav", e.data.url, "allowed", e.data.allowed);
});

Security checklist:

  • Use sandbox: true for untrusted content.
  • Apply strict navigation allowlists.
  • Use separate partition values for isolation.
  • Validate all host-message payloads from <electrobun-webview> preload scripts.
  • Do not write to PATHS.RESOURCES_FOLDER at runtime; use Utils.paths.userData.

Typed RPC (Minimal Pattern)

// src/shared/types.ts
import type { RPCSchema } from "electrobun/bun";

export type MyRPC = {
  bun: RPCSchema<{
    requests: {
      getUser: { params: { id: string }; response: { name: string } };
    };
    messages: {
      logToBun: { msg: string };
    };
  }>;
  webview: RPCSchema<{
    requests: {
      updateUI: { params: { html: string }; response: boolean };
    };
    messages: {
      notify: { text: string };
    };
  }>;
};
// bun side
import { BrowserView, BrowserWindow } from "electrobun/bun";
import type { MyRPC } from "../shared/types";

const rpc = BrowserView.defineRPC<MyRPC>({
  handlers: {
    requests: {
      getUser: ({ id }) => ({ name: `user-${id}` }),
    },
    messages: {
      logToBun: ({ msg }) => console.log(msg),
    },
  },
});

const win = new BrowserWindow({
  title: "App",
  url: "views://mainview/index.html",
  rpc,
});

await win.webview.rpc.updateUI({ html: "<p>Hello</p>" });
// browser side
import { Electroview } from "electrobun/view";
import type { MyRPC } from "../shared/types";

const rpc = Electroview.defineRPC<MyRPC>({
  handlers: {
    requests: {
      updateUI: ({ html }) => {
        document.body.innerHTML = html;
        return true;
      },
    },
    messages: {
      notify: ({ text }) => console.log(text),
    },
  },
});

const electroview = new Electroview({ rpc });
await electroview.rpc.request.getUser({ id: "1" });
electroview.rpc.send.logToBun({ msg: "hello" });

Events and Shutdown

Use before-quit for shutdown cleanup instead of relying on process.on("exit") for async work.

import Electrobun from "electrobun/bun";

Electrobun.events.on("before-quit", async (e) => {
  await saveState();
  // e.response = { allow: false }; // optional: cancel quit
});

Important caveat:

  • Linux currently has a caveat where some system-initiated quit paths (for example Ctrl+C/window-manager/taskbar quit) may not fire before-quit. Programmatic quit via Utils.quit()/process.exit() is reliable.

Common Patterns

  • Keyboard shortcuts (copy/paste/undo): define an Edit ApplicationMenu with role-based items.
  • Tray-only app: set runtime.exitOnLastWindowClosed: false, then drive UX from Tray.
  • Multi-account isolation: use separate partition values per account.
  • Chromium consistency: set bundleCEF: true and defaultRenderer: "cef" in platform config.

Troubleshooting

  • RPC calls fail unexpectedly:
  • Check whether the target webview is sandboxed (sandbox: true disables RPC).
  • Confirm shared RPC types match both bun and browser handlers.
  • Navigation blocks legitimate URLs:
  • Review setNavigationRules ordering; last match wins.
  • Keep ^* first only when you intentionally run strict allowlist mode.
  • Updater says no update:
  • Verify release.baseUrl and uploaded artifacts/ naming ({channel}-{os}-{arch}-...).
  • Confirm channel/build env alignment (canary vs stable).
  • User sessions leak across accounts:
  • Use explicit per-account partitions and manage cookies via Session.fromPartition(...).
  • Build hooks not running:
  • Ensure hook paths are correct and executable via Bun.
  • Inspect hook env vars (for example ELECTROBUN_BUILD_ENV, ELECTROBUN_OS, ELECTROBUN_ARCH).

Reference Files

  • Build config, artifacts, and hooks: reference/build-config.md
  • BrowserWindow, BrowserView, and webview tag APIs: reference/window-and-webview.md
  • Menus, tray, events, updater, utils/session APIs: reference/platform-apis.md

Related skills

How it compares

Pick electrobun-best-practices when bundle size and TypeScript-only tooling matter more than Electron's rendering consistency guarantees.

FAQ

What runtime does electrobun-best-practices use for the main process?

electrobun-best-practices targets Electrobun with Bun as the main-process runtime and bundler. The renderer uses the host OS system webview—WKWebView on macOS, WebView2 on Windows, and WebKitGTK on Linux—keeping bundles small compared to Chromium-based frameworks.

How does electrobun-best-practices handle Linux rendering quirks?

electrobun-best-practices recommends setting bundleCEF to true in electrobun.config.ts on Linux and opening BrowserWindow instances with renderer set to cef when GTK WebKit limitations affect layering. CI matrix builds on native runners per OS are the recommended release path.

Frontend Developmentfrontendbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.