{"id":19787941,"url":"https://github.com/i2y/wasabi","last_synced_at":"2026-05-08T06:12:20.523Z","repository":{"id":188068750,"uuid":"657161000","full_name":"i2y/wasabi","owner":"i2y","description":"A cross-platform UI framework for Go","archived":false,"fork":false,"pushed_at":"2023-06-25T15:57:04.000Z","size":4050,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-11T03:45:15.581Z","etag":null,"topics":["cross-platform","go","golang","gui","ui","websocket","webview","webview2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i2y.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-22T12:57:49.000Z","updated_at":"2023-07-08T08:17:10.000Z","dependencies_parsed_at":"2023-08-13T16:12:18.655Z","dependency_job_id":null,"html_url":"https://github.com/i2y/wasabi","commit_stats":null,"previous_names":["i2y/wasabi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2y%2Fwasabi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2y%2Fwasabi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2y%2Fwasabi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i2y%2Fwasabi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i2y","download_url":"https://codeload.github.com/i2y/wasabi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241121449,"owners_count":19913277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","go","golang","gui","ui","websocket","webview","webview2"],"created_at":"2024-11-12T06:25:16.784Z","updated_at":"2025-11-23T06:04:32.011Z","avatar_url":"https://github.com/i2y.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wasabi\nWasabi is a cross-platform UI framework for creating desktop and web applications using only Go.\n\n## Features\n- Wasabi enables you to create both desktop and web apps using only Go. A little knowledge of HTML/CSS can help.\n- It works seamlessly with CSS frameworks like [Tailwind CSS](https://tailwindcss.com/) and [daisyUI](https://daisyui.com/).\n- It simplifies development by unifying backend and frontend, minimizing data transfer and eliminating the need for JavaScript or backend APIs.\n- It has declarative UI flavor.\n\n## A Quick Overview\nThis example showcases a simple counter application created using Wasabi.\nThe source code of this example is available [here](example/counter/desktop/main.go)\n\nThis example uses [daisyUI](https://daisyui.com/) as a CSS framework.\n\n### Directory tree\n\n```\nroot\n├── main.go\n└── assets\n    ├── daisyui.css\n    └── tailwind.js\n```\n\n### Source (main.go)\n```go\npackage main\n\nimport (\n    \"embed\"\n    \"strconv\"\n\n    w \"github.com/i2y/wasabi\"\n    a \"github.com/i2y/wasabi/modifier/attr\"\n)\n\n//go:embed assets\nvar assets embed.FS\n\nfunc main() {\n    app := w.NewDesktopApp(\"counter\", 800, 600, w.Assets(assets))\n    app.Run(counter)\n}\n\nfunc counter(f *w.Factory) w.Element {\n    count := w.NewState(0)\n    return f.Div(a.Class(\"flex items-center justify-center w-screen h-screen\"))(\n        f.Button(\n            a.Class(\"btn text-4xl w-24 h-24 items-center justify-center\"),\n            a.OnClick(func() { count.Set(count.Get() + 1) }),\n        )(\n            f.Text(\"+\"),\n        ),\n        f.Reactive(count, func() w.Element {\n            return f.Div(a.Class(\"text-slate-400 text-4xl w-24 h-24 flex items-center justify-center\"))(\n                f.Text(strconv.Itoa(count.Get())),\n            )\n        }),\n        f.Button(\n            a.Class(\"btn text-4xl w-24 h-24 items-center justify-center\"),\n            a.OnClick(func() { count.Set(count.Get() - 1) }),\n        )(\n            f.Text(\"-\"),\n        ),\n    )\n}\n```\n\nThe following part may be the most important part of the code above.\n\n```go\nf.Reactive(count, func() w.Element {\n    return f.Div(a.Class(\"text-slate-400 text-4xl w-24 h-24 flex items-center justify-center\"))(\n        f.Text(strconv.Itoa(count.Get())),\n    )\n}),\n\n```\n`wasabi.Reactive` is a function that takes a state and a generator function for an element. Initially, it calls the function with the initial state to make the first element. When the state changes, it makes a new element and replaces the old one calling the function with the updated state.\n\n### Build and Run\n```sh\ngo build main.go\n./main\n```\n\n### Screen Shot\n\u003cimg width=\"215\" alt=\"Counter\" src=\"screenshot.png\"\u003e\n\n### Other Examples\n- [Calculator](example/calc/main.go)\n- ...\n\n## Dependencies\nWasabi currently depends on the following packages.\nThanks to the creators and contributors of each package.\n- [go-webview2](https://github.com/jchv/go-webview2) for windows\n- [webview](https://github.com/webview/webview) for other platforms\n- [nhooyr.io/websocket](https://github.com/nhooyr/websocket) for communication between Go and webview\n- [Hotwired Turbo](https://turbo.hotwired.dev/) for the same purpose as above\n- [EventBus](https://github.com/asaskevich/eventbus)\n- and libraries that the above libraries depend on\n\nThese dependencies may be changed for internal implementation reasons.\n\n## Distribution/Packaging\nIf you intend to package and distribute your application, you essentially just need to execute the `go build` command with the suitable `GOOS` and `GOARCH` parameters. Nonetheless, there are several platform-specific considerations to bear in mind.\n\n### MacOS\nYou can create an application bundle (`.app` package) using tools like [appify](https://github.com/machinebox/appify) or [macappshell](https://github.com/Xeoncross/macappshell).\n\n### Windows\nYour application can be run in the background by specifying the `-ldflags \"-H windowsgui\"` option during the `go build` process. For instance:\n```\ngo build -ldflags \"-H windowsgui\" main.go\n```\nAdditionally, you can utilize tools such as [go-winres](https://github.com/tc-hib/go-winres), [rsrc](https://github.com/akavel/rsrc), or [GoVersionInfo](https://github.com/josephspurrier/goversioninfo) to embed resources, like the application icon, into your Windows app.\n\n## Web App Example\nThe source code for running the aforementioned Counter desktop app example as a web application can be found [here](example/counter/web/main.go).\n\n### Directory Structure\n```\nroot\n├── main.go\n└── counter/assets\n    ├── daisyui.css\n    └── tailwind.js\n```\n\n### Source (main.go)\n```go\npackage main\n\nimport (\n    \"embed\"\n    \"net/http\"\n    \"strconv\"\n\n    w \"github.com/i2y/wasabi\"\n    a \"github.com/i2y/wasabi/modifier/attr\"\n)\n\n//go:embed counter/assets\nvar assets embed.FS\n\nfunc main() {\n    handler := w.NewHTTPHandler(\"counter\", \"/counter\", counter, w.Assets(assets))\n    http.ListenAndServe(\":8080\", handler)\n}\n\nfunc counter(f *w.Factory) w.Element {\n    count := w.NewState(0)\n    return f.Div(a.Class(\"flex items-center justify-center w-screen h-screen\"))(\n        f.Button(\n            a.Class(\"btn text-4xl w-24 h-24 items-center justify-center\"),\n            a.OnClick(func() { count.Set(count.Get() + 1) }),\n        )(\n            f.Text(\"+\"),\n        ),\n        f.Reactive(count, func() w.Element {\n            return f.Div(a.Class(\"text-slate-400 text-4xl w-24 h-24 flex items-center justify-center\"))(\n                f.Text(strconv.Itoa(count.Get())),\n            )\n        }),\n        f.Button(\n            a.Class(\"btn text-4xl w-24 h-24 items-center justify-center\"),\n            a.OnClick(func() { count.Set(count.Get() - 1) }),\n        )(\n            f.Text(\"-\"),\n        ),\n    )\n}\n```\n\nThe key differences from the desktop app include the use of `w.NewHTTPHandler` instead of `w.NewDesktopApp`. While Wasabi's backend core uses a websocket, it's fundamentally just a net/http handler. This not only enables users to create web apps using Wasabi, but also allows for the integration of Wasabi with other web frameworks.\n\n### Build and Run\n```sh\ngo build main.go\n./main\n```\n\nYou can access the application at `http://localhost:8080/counter`.\n\n## Architecture\n\u003cimg width=\"600\" alt=\"Desktop App Architecture\" src=\"diagram/desktopapp.png\"\u003e\n\n\u003cimg width=\"600\" alt=\"Web App Architecture\" src=\"diagram/webapp.png\"\u003e\n\nThe communication between the Go backend and the browser/webview is done via a websocket. The Go backend sends the HTML/CSS/JS code to the browser/webview, and the browser/webview sends the events to the Go backend.\n\n## License\n[MIT License](https://github.com/i2y/wasabi/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi2y%2Fwasabi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi2y%2Fwasabi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi2y%2Fwasabi/lists"}