1
0
Fork
You've already forked zuil
0
Pure Zig webview library.
  • Zig 95.7%
  • Nix 4.3%
Quint Daenen efb6490ca7 feat: expose module for dependents and add thread-safe JS evaluation
Use b.addModule instead of b.createModule so downstream packages
can import zuil as a dependency. Add dispatchEvaluateJs() which
dispatches JS evaluation to the main thread via GCD.
2026年04月07日 09:03:14 +02:00
examples feat: expose module for dependents and add thread-safe JS evaluation 2026年04月07日 09:03:14 +02:00
src feat: expose module for dependents and add thread-safe JS evaluation 2026年04月07日 09:03:14 +02:00
.gitignore feat: pure Zig WebView for macOS using direct ObjC runtime calls 2026年04月07日 08:36:42 +02:00
build.zig feat: expose module for dependents and add thread-safe JS evaluation 2026年04月07日 09:03:14 +02:00
build.zig.zon feat: pure Zig WebView for macOS using direct ObjC runtime calls 2026年04月07日 08:36:42 +02:00
flake.lock feat: pure Zig WebView for macOS using direct ObjC runtime calls 2026年04月07日 08:36:42 +02:00
flake.nix feat: pure Zig WebView for macOS using direct ObjC runtime calls 2026年04月07日 08:36:42 +02:00
LICENSE feat: pure Zig WebView for macOS using direct ObjC runtime calls 2026年04月07日 08:36:42 +02:00
README.md feat: expose module for dependents and add thread-safe JS evaluation 2026年04月07日 09:03:14 +02:00

ZUIL - Zig UI Library

A zuil (Dutch, noun) is primarily a vertical structure—a pillar, column, or post, used to support or adorn a building.

Pure Zig webview library. Calls the platform's native web engine directly through C interop with zero external dependencies.

Platforms

Platform Engine Status
macOS WebKit (WKWebView) Working
Linux WebKitGTK Planned
Windows WebView2 Planned

Usage

constzuil=@import("zuil");pubfnmain()void{varwv:zuil.WebView=.{};wv.init(.{.title="My App",.width=1024,.height=768,.html="<h1>Hello from Zig</h1>",.callback=&onMessage,});wv.run();}fnonMessage(msg:[]constu8)void{std.debug.print("JS: {s}\n",.{msg});}

API

Method Description
init(Options) Create window and webview
run() Enter the event loop
evaluateJs(js) Execute JavaScript
dispatchEvaluateJs(js) Execute JavaScript from any thread
setTitle(title) Change window title
setHtml(html) Load HTML content
navigate(url) Navigate to a URL
terminate() Quit the application

JS Bridge

JavaScript can send messages to Zig via zuil.postMessage(string), which is injected automatically. Messages arrive at the callback function passed in Options.

Building

Requires Zig 0.15+ and Nix (for the dev shell).

nix develop
zig build run # run the example
zig build test # run tests

License

MPL-2.0