← back

native-window

[beta]
TypeScript, Rust ★ 1
[native-window][bun][deno][typescript][desktop][webview]

Create native desktop windows with embedded web content from Bun, Deno & Node.js

A Rust napi-rs addon built on wry and tao that uses platform-native webview engines — WebKit on macOS and Linux, WebView2 on Windows — to create real desktop windows with embedded web content from Bun, Deno & Node.js. No Electron or Chromium bundled.

Motivation

I needed a way to open native windows from Elgato Stream Deck plugins — to expand on a key’s details or provide richer interaction beyond the small key UI. There was no lightweight way to do this without pulling in Electron or dealing with signed external webview runtimes that support bidirectional communication between the host process and the webview.

Features

  • Cross-platform webviews — WebKit on macOS/Linux, WebView2 on Windows
  • Multi-window — create and manage multiple independent windows
  • HTML & URL loading — load inline HTML strings or navigate to URLs
  • Typed IPC — schema-first messaging layer with compile-time type checking and runtime validation via Zod, Valibot, or any safeParse()-compatible library
  • React hooksuseChannelEvent, useSend, and ChannelProvider for idiomatic React integration
  • Full window control — title, size, position, min/max size, decorations, transparency, always-on-top
  • Window events — close, resize, move, focus, blur, page load, title change
  • Security hardening — URL scheme blocking, CSP, trusted origin filtering, IPC bridge hardening, message size limits, schema validation
  • Runtime detectioncheckRuntime() and ensureRuntime() for WebView2 availability on Windows

Getting started

bun add @nativewindow/webview
import { init, NativeWindow } from "@nativewindow/webview";

const win = new NativeWindow({
  title: "My App",
  width: 800,
  height: 600,
});

win.loadUrl("https://myapp.com");

win.onClose(() => {
  process.exit(0);
});