gitmyhub

webview

C++ ★ 14k updated 3mo ago

Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).

A tiny C and C++ library for building cross-platform desktop apps with an HTML, CSS, and JavaScript interface, using the OS's own browser engine on Linux, macOS, and Windows.

CC++CMakeWebKitGTKWebView2setup: moderatecomplexity 3/5

webview is a small C and C++ library that lets developers build desktop applications with a user interface written in HTML, CSS, and JavaScript. Instead of creating native buttons and windows from scratch using platform-specific code, the application uses a web browser component to display its interface. The library handles the differences between operating systems so the same code can run on Linux, macOS, and Windows.

On Linux it uses GTK and WebKitGTK as the underlying browser component. On macOS it uses the native WebKit framework built into the operating system. On Windows it uses Microsoft's Edge WebView2, which requires the WebView2 runtime to be installed (this comes pre-installed on Windows 11; older versions of Windows need it added separately).

One of the key features is two-way communication between the C or C++ code and the JavaScript running inside the web view. You can call JavaScript functions from your C++ code, and you can also call back into C++ from JavaScript. This lets the visible interface and the underlying application logic stay connected without much extra setup.

The library is distributed as a header file, which makes it easy to add to a project without a complicated build process. The README includes working examples in both C and C++ using CMake, showing how to open a window, set its title and size, and load HTML content. There are also instructions for compiling without CMake by invoking the compiler directly.

The project describes itself as trying to provide a common HTML5 interface layer across major platforms. Documentation is embedded in the source code itself, and contributions to both documentation and code are welcomed through GitHub.

Where it fits