DEV Community

Alex Spinov
Alex Spinov

Posted on

Wails Has a Free API: Build Desktop Apps in Go With Web Frontends

Electron uses JavaScript for everything. Tauri uses Rust. Wails uses Go — and if you're a Go developer, it's the obvious choice.

What Is Wails?

Wails builds desktop applications using Go for the backend and any web framework for the frontend. Like Tauri, it uses the OS's native webview instead of bundling Chromium.

wails init -n myapp -t svelte-ts
cd myapp
wails dev
Enter fullscreen mode Exit fullscreen mode

Go ↔ Frontend Communication

// app.go
package main

type App struct {
    ctx context.Context
}

func (a *App) Greet(name string) string {
    return fmt.Sprintf("Hello %s, welcome to Wails!", name)
}

func (a *App) ReadFile(path string) (string, error) {
    data, err := os.ReadFile(path)
    return string(data), err
}

func (a *App) FetchURL(url string) (map[string]any, error) {
    resp, err := http.Get(url)
    if err != nil { return nil, err }
    defer resp.Body.Close()
    var result map[string]any
    json.NewDecoder(resp.Body).Decode(&result)
    return result, nil
}
Enter fullscreen mode Exit fullscreen mode
// Frontend — auto-generated TypeScript bindings!
import { Greet, ReadFile, FetchURL } from '../wailsjs/go/main/App'

const greeting = await Greet("World")
const fileContent = await ReadFile("/path/to/file.txt")
const apiData = await FetchURL("https://api.example.com/data")
Enter fullscreen mode Exit fullscreen mode

Wails automatically generates TypeScript bindings from your Go functions. Full type safety across the boundary.

Why Wails

  • Go backend — goroutines, channels, entire Go ecosystem
  • 3-10MB binary — vs Electron's 150MB+
  • Auto-generated bindings — Go functions → TypeScript, automatically
  • Native menus, dialogs, tray — platform-native UI elements
  • Hot reload — frontend and backend hot reload during development
  • Cross-compile — macOS, Windows, Linux from one codebase

A Go developer built a Kubernetes dashboard with Wails. It's a 8MB binary that uses 25MB RAM. The Electron equivalent would be 200MB+.


Building desktop apps in Go? Check out my developer tools or email spinov001@gmail.com.

Top comments (0)