Skip to content
This repository was archived by the owner on Sep 10, 2026. It is now read-only.

Repository files navigation

webkitgtk Go Reference Release Go Report Card License

📦 webkitgtk is deprecated - say hello to appkit 🎉

After a good run, webkitgtk is being replaced by appkit - a ground-up rewrite with no cgo, so you can cross-compile to Windows, macOS, Linux, FreeBSD and NetBSD from one machine with just GOOS/GOARCH. It binds the OS web engine directly (WKWebView / WebKitGTK / WebView2) behind a single *App API, with an isolated app:// origin, a Go↔JS bridge, tray, notifications, dialogs and frameless windows - no engine is bundled.

Thank you to everyone who used webkitgtk! ❤️

Installation

# go 1.21.5+
go get github.com/malivvan/webkitgtk@latest

Example

The following example shows how to create a simple GTK window with a button that closes the application when clicked.

package main

import ui "github.com/malivvan/webkitgtk"

type API struct {
	app *ui.App
}

func (a *API) Quit() error {
	a.app.Quit()
	return nil
}

func main() {
	app := ui.New(ui.AppOptions{
		Name: "example",
	})
	app.Open(ui.WindowOptions{
		Title: "example",
		HTML:  `<button onclick="app.quit()">quit</button>`,
		Define: map[string]interface{}{
			"app": &API{app: app},
		},
	})
	if err := app.Run(); err != nil {
		panic(err)
	}
}

Running / Building

Running / building defaults to debug mode outputting logs to stderr. To build in release mode use the release build tag.

go build -tags release -ldflags "-s -w" -trimpath

The resulting release binary will be about ~6MB in size and cam be compressed further with UPX to about ~2.5MB.

Examples

  • echo - call go functions from javascript
  • dialog - application spawning different types of dialog windows
  • handle - handle requests on the app:// uri scheme to serve embedded files
  • notify - application sending different types of notifications
  • systray - example application showing how to use the systray

Dependencies

Either webkit2gtk-4.1 (stable) or webkitgtk-6.0 (unstable) is required at runtime. If both are installed the stable version will be used.

Debian / Ubuntu apt install libwebkit2gtk-4.1 apt install libwebkitgtk-6.0
RHEL / Fedora dnf install webkitgtk4 dnf install webkitgtk3
Arch pacman -S webkit2gtk-4.1 pacman -S webkitgtk-6.0
Alpine apk add webkit2gtk apk add webkit2gtk-6.0
Gentoo emerge -av net-libs/webkit-gtk
FreeBSD pkg install webkit2-gtk3 pkg install webkit2-gtk4

License

This project is licensed under the MIT License.

About

pure Go WebKitGTK binding for Linux and FreeBSD

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages