# webview — Tiny Cross-Platform Web-Based Desktop UI Library
> Embed a native webview in C, C++, Go, Rust, or Python applications to build lightweight desktop apps using HTML, CSS, and JavaScript without bundling a full browser engine.
## Install
Save in your project root:
# webview — Tiny Cross-Platform Web-Based Desktop UI Library
## Quick Use
```bash
# Go example
go mod init myapp
go get github.com/webview/webview_go
cat > main.go << EOF
package main
import "github.com/webview/webview_go"
func main() {
w := webview.New(true)
defer w.Destroy()
w.SetTitle("Hello")
w.SetSize(480, 320, webview.HintNone)
w.SetHtml("
Hello from webview!
")
w.Run()
}
EOF
go run .
```
## Introduction
webview is a minimal cross-platform library that provides a native webview window for building desktop applications with web technologies. Instead of bundling Chromium like Electron, it uses the platform's built-in web engine — WebKit on macOS, WebKitGTK on Linux, and WebView2 (Edge/Chromium) on Windows — resulting in tiny binary sizes and low memory usage.
## What webview Does
- Opens a native window with an embedded web renderer on Windows, macOS, and Linux
- Supports two-way bindings between native code and JavaScript in the webview
- Uses the system's built-in browser engine, producing binaries under 2 MB
- Provides C/C++ core API with official bindings for Go, Rust, Python, and other languages
- Handles window management, title, size, and hints through a simple API
## Architecture Overview
The library is a thin C/C++ wrapper around platform-specific webview implementations. On macOS it uses WKWebView via Cocoa, on Linux it uses WebKitGTK, and on Windows it leverages WebView2 (the Edge-based runtime). A small message-passing bridge connects the native side to JavaScript running in the webview, enabling `window.external.invoke()` calls from JS and `webview.Eval()` calls from native code. The entire core is a single-header C++ library.
## Self-Hosting & Configuration
- For Go: `go get github.com/webview/webview_go`; for Rust: add `webview` crate to Cargo.toml
- On Linux, install `libwebkit2gtk-4.1-dev` as a build dependency
- On Windows, the WebView2 runtime ships with Windows 10/11 or can be bootstrapped automatically
- Set window dimensions, title, and resize hints via the constructor or setter methods
- Serve HTML inline via `SetHtml()` or load a URL via `Navigate()`
## Key Features
- Extremely small footprint: no bundled browser engine, final binary typically under 2 MB
- Two-way JS ↔ native binding for calling Go/Rust/C++ functions from the web UI
- Supports loading local HTML, remote URLs, or data URIs
- Window resize hints (none, min, max, fixed) for controlling user resizing behavior
- Thread-safe dispatch function for updating the webview from background threads
## Comparison with Similar Tools
- **Electron** — Bundles full Chromium (~150 MB); webview uses the system engine at a fraction of the size
- **Tauri** — Rust-based framework that also uses system webviews but adds a full app framework; webview is lower-level
- **Wry** — Tauri's webview abstraction layer; webview is simpler with fewer features and wider language support
- **Neutralinojs** — Lightweight alternative to Electron; webview is even more minimal as a library rather than a framework
- **CEF (Chromium Embedded)** — Full Chromium embedding for C++; webview trades features for simplicity and size
## FAQ
**Q: Does webview support all modern web APIs?**
A: It depends on the platform's browser engine version. WebView2 on Windows and WKWebView on macOS support most modern APIs. Linux depends on the installed WebKitGTK version.
**Q: Can I use frameworks like React or Vue inside webview?**
A: Yes. You can serve a bundled SPA via a local file or embedded HTTP server and load it in the webview.
**Q: How do I package the app for distribution?**
A: Compile your native binary as usual. On Windows, consider bundling the WebView2 bootstrapper. On macOS, create an .app bundle. The binary itself needs no additional runtime.
**Q: Is webview suitable for complex production apps?**
A: It works well for utilities, dashboards, and internal tools. For complex apps requiring native menus, tray icons, or system integration, a full framework like Tauri may be more appropriate.
## Sources
- https://github.com/webview/webview
- https://webview.dev/
---
Source: https://tokrepo.com/en/workflows/asset-02173b44
Author: AI Open Source