Wails — Build Desktop Apps with Go and Web Technologies
Wails lets you create beautiful desktop applications using Go for the backend and any web frontend. Uses the OS native WebView (like Tauri) producing ~8MB binaries. No Electron bloat, full Go power, and access to native APIs via bindings.
Agent 可直接安装
这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。
npx -y tokrepo@latest install 42404fb6-364b-11f1-9bc6-00163e2b0d79 --target codex先 dry-run 确认安装计划,再运行此命令。
What it is
Wails is a framework for building desktop applications using Go for the backend and any web technology (React, Svelte, Vue) for the frontend. Unlike Electron, which bundles a full Chromium instance, Wails uses the operating system's native WebView. This produces binaries around 8MB instead of 150MB+.
Wails targets Go developers who need to build desktop GUIs without learning a native UI toolkit. If you already know Go and a web framework, Wails lets you combine both into a single distributable binary for Windows, macOS, and Linux.
How it saves time or tokens
Building a desktop app with native toolkits (Qt, GTK, Cocoa) requires learning platform-specific APIs. Wails eliminates this by letting you reuse existing web development skills for the UI while writing performance-critical logic in Go.
The Go-to-JavaScript binding system is automatic. You define Go methods, and Wails generates TypeScript bindings that your frontend can call directly. No REST API, no WebSocket plumbing, no serialization boilerplate.
How to use
- Install the Wails CLI and scaffold a project:
go install github.com/wailsapp/wails/v2/cmd/wails@latest
wails init -n myapp -t svelte-ts
cd myapp
- Write your Go backend logic:
type App struct {
ctx context.Context
}
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s from Go!", name)
}
- Call Go functions from the frontend:
<script lang="ts">
import { Greet } from '../wailsjs/go/main/App';
let result = '';
async function greet() {
result = await Greet('World');
}
</script>
<button on:click={greet}>{result || 'Click me'}</button>
- Run in development or build for production:
wails dev # Hot-reload dev mode
wails build # Production binary
Example
A minimal file manager backend in Go:
func (a *App) ListFiles(dir string) ([]string, error) {
entries, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
var names []string
for _, e := range entries {
names = append(names, e.Name())
}
return names, nil
}
The frontend calls ListFiles('/home/user') and renders the result in a web-based file browser UI.
Related on TokRepo
- Coding AI tools -- developer tools for building applications
- Automation tools -- desktop and workflow automation
Common pitfalls
- WebView rendering varies across operating systems. Test your UI on all target platforms, especially Linux where WebView implementations differ between distributions.
- Wails v2 does not support mobile platforms. If you need iOS or Android targets, consider alternatives like Flutter or Tauri Mobile.
- Large file transfers between Go and JavaScript go through JSON serialization. For binary data or large datasets, consider writing results to disk and passing file paths instead.
常见问题
Wails uses the OS native WebView instead of bundling Chromium, producing 8MB binaries versus Electron's 150MB+. Memory usage is lower, and startup is faster. The trade-off is that WebView behavior varies slightly across platforms, while Electron provides a consistent Chromium environment.
Wails supports React, Vue, Svelte, Angular, and vanilla JavaScript/TypeScript. The CLI provides starter templates for each framework. You can also bring your own frontend setup by configuring the wails.json file.
Yes. Wails provides runtime APIs for native dialogs, menus, system tray, clipboard, and window management. For anything beyond the built-in APIs, you write Go code that calls native libraries via cgo or pure Go packages.
Wails v2 is stable and used in production applications. The project is actively maintained with regular releases. Code signing and distribution packaging (DMG, MSI, AppImage) are supported through the build system.
Wails scans your Go structs for exported methods and generates TypeScript bindings in the wailsjs directory. These bindings handle JSON serialization and deserialization automatically. You call Go functions from JavaScript as if they were async TypeScript functions.
引用来源 (3)
- Wails GitHub— Wails uses native OS WebView for small binary sizes
- Wails Documentation— Auto-generated TypeScript bindings from Go structs
- Wails Architecture— WebView2 on Windows, WebKit on macOS and Linux
讨论
相关资产
webview — Tiny Cross-Platform Web-Based Desktop UI Library
Embed a native webview in C, C++, Go, Rust, or Python applications to build lightweight desktop apps using HTML, CSS, and JavaScript without bundling a full browser engine.
Compose Multiplatform — Kotlin UI for Desktop, iOS & Web
Build rich user interfaces for Android, iOS, desktop, and web from a shared Kotlin codebase using JetBrains' declarative Compose UI toolkit.
Uno Platform — Pixel-Perfect Multi-Platform Apps with .NET
Build native mobile, desktop, and web applications from a single C# and XAML codebase targeting Windows, iOS, Android, macOS, Linux, and WebAssembly with pixel-perfect fidelity.
Neutralino.js — Lightweight Desktop App Framework Without Heavy Runtimes
Build cross-platform desktop applications with HTML, CSS, and JavaScript that ship as tiny binaries without bundling a browser engine. Neutralino uses the operating system's native WebView and exposes system APIs through a lightweight runtime.