Webview is a wrapper for Webview, a tiny cross-platform webview library for C/C++ to build modern cross-platform GUIs. Webview (the wrapper) supports two-way JavaScript bindings, to call JavaScript from Nim and to call Nim from JavaScript.
Webview is also an updated wrapper for Webview for Nim than oskca's bindings, which were last updated 5 years ago and are severely out of date.
Similar to uing
, you can also choose to
whether or not compile with a DLL, static library, or to statically compile Webview
sources into your executable.
To compile with a DLL, pass -d:useWebviewDll
to the Nim compiler. You can also
choose the name/path of the DLL with -d:webviewDll:<dll-name>
.
To compile with a static library, compile with -d:useWebviewStaticLib
or
-d:useWebviewStaticLibrary
. Similarly, you can also
choose the name/path of the static library with -d:webviewStaticLibrary:<lib-name>
.
Documentation is available at https://neroist.github.io/webview
Examples can be found at examples/
. Currently, it contains two
examples, basic.nim
, a basic example of Webview, and bind.nim
, an example of
calling Nim from Javascript with Webview. In addition, it also has an example
application in the structure described
here.
Here's basic.nim
for you:
import webview
let w = newWebview() # or you can use create()
w.title = "Basic Example" # or use setTitle()
w.size = (480, 320) # or setSize()
w.html = "Thanks for using webview!" # or setHtml()
w.run()
w.destroy()
Install via Nimble:
nimble install https://github.com/neroist/webview
This package isn't in Nimble's package list, so you have to install via GitHub link.
On Windows, Webview requires that developers and end-users must have the WebView2 runtime installed on their system for any version of Windows before Windows 11. The WebView2 SDK is installed for you, so no need to worry about that.
On Linux and BSD, Only GTK3 and WebKitGTK are required for both development and distribution. See here.
See here in Webview's README.