# Wry — Cross-Platform WebView Rendering Library for Rust > A Rust library for creating cross-platform desktop applications with web-based UIs by leveraging each operating system's native webview engine with minimal overhead. ## Install Save in your project root: # Wry — Cross-Platform WebView Rendering Library for Rust ## Quick Use ```bash cargo new wry-demo && cd wry-demo cargo add wry tao cat > src/main.rs << 'RUSTEOF' use tao::event_loop::EventLoop; use tao::window::WindowBuilder; use wry::WebViewBuilder; fn main() { let event_loop = EventLoop::new(); let window = WindowBuilder::new() .with_title("Wry Demo") .build(&event_loop) .unwrap(); let _webview = WebViewBuilder::new(&window) .with_html("

Hello from Wry!

") .build() .unwrap(); event_loop.run(move |_, _, _| {}); } RUSTEOF cargo run ``` ## Introduction Wry is a cross-platform webview rendering library written in Rust that powers the Tauri framework. It provides a unified API for embedding the operating system's native webview engine — WebKit on macOS and Linux, WebView2 on Windows — into Rust desktop applications, enabling developers to build lightweight apps with web-based UIs without bundling a browser engine. ## What Wry Does - Embeds the system's native webview into a Rust application window on Windows, macOS, and Linux - Provides IPC (inter-process communication) between Rust backend code and JavaScript in the webview - Supports loading HTML strings, local files, and remote URLs in the webview - Handles custom protocol registration for serving local assets via custom URI schemes - Integrates with the Tao window management library for cross-platform window creation and event handling ## Architecture Overview Wry abstracts platform-specific webview APIs behind a common Rust interface. On macOS it uses WKWebView via the objc2 crate, on Linux it uses WebKitGTK through gtk-rs bindings, and on Windows it uses the WebView2 COM API. Window management is delegated to Tao, a fork of winit with additional features needed for webview hosting. The IPC bridge serializes messages between the Rust and JavaScript sides using a custom protocol handler, avoiding the overhead of a separate HTTP server. ## Self-Hosting & Configuration - Add `wry` and `tao` to your `Cargo.toml` dependencies - On Linux, install `libwebkit2gtk-4.1-dev` and `libgtk-3-dev` as system dependencies - On Windows, WebView2 runtime is pre-installed on Windows 10/11; for older systems include the Evergreen bootstrapper - Configure webview settings: user agent, custom protocols, dev tools visibility, and transparent backgrounds - Use `with_ipc_handler()` to set up Rust callbacks triggered from JavaScript via `window.ipc.postMessage()` ## Key Features - System webview reuse: no bundled Chromium, resulting in tiny binary sizes (typically 2-5 MB) - Bidirectional Rust-to-JavaScript IPC for calling native functions from the web UI and vice versa - Custom protocol handlers to serve local files and assets without an HTTP server - Transparent and decorationless window support for creating custom-shaped UIs - Foundation of the Tauri ecosystem, battle-tested in thousands of production Tauri applications ## Comparison with Similar Tools - **Tauri** — Full application framework built on top of Wry; Wry is the lower-level webview layer for those who want more control - **webview (C/C++)** — Similar concept in C; Wry is Rust-native with stronger type safety and the Tao event loop - **Electron** — Bundles full Chromium (~150 MB); Wry uses system webviews for a fraction of the size and memory - **Sciter** — Embeddable HTML/CSS renderer; Wry uses real browser engines with full web standards support - **CEF** — Full Chromium embedding; Wry trades Chromium's full API surface for minimal binary size and system integration ## FAQ **Q: Is Wry the same thing as Tauri?** A: No. Wry is the webview rendering library that Tauri uses under the hood. You can use Wry directly for lower-level control or use Tauri for a complete application framework experience. **Q: Does Wry support all web APIs?** A: It supports whatever the platform's webview engine supports. WebView2 on Windows and WebKit on macOS cover most modern web APIs. Linux depends on the installed WebKitGTK version. **Q: Can I use React, Vue, or Svelte with Wry?** A: Yes. Build your frontend with any web framework and either bundle the static assets for loading via custom protocols or serve them from a local dev server. **Q: How does Wry handle multi-window applications?** A: Wry supports creating multiple webview instances, each attached to its own Tao window, within the same event loop. ## Sources - https://github.com/nicknisi/tauri-apps/wry - https://docs.rs/wry/ --- Source: https://tokrepo.com/en/workflows/asset-7f80eef3 Author: AI Open Source