Introduction
Lorca is a minimalist Go library that turns any HTML5 page into a desktop application by launching Chrome or Chromium in app mode and communicating with it via the Chrome DevTools Protocol. It requires no bundled browser engine, keeping your application tiny while still delivering a modern web UI.
What Lorca Does
- Opens a Chrome window in app mode without the address bar, tabs, or browser UI
- Communicates between Go and the browser through the Chrome DevTools Protocol
- Lets Go code call JavaScript functions and receive return values
- Lets JavaScript call Go functions that have been explicitly bound
- Supports loading local HTML files or remote URLs as the application interface
Architecture Overview
Lorca starts Chrome as a subprocess with the --app flag and connects to its remote debugging port via WebSocket. All communication flows through the Chrome DevTools Protocol: Go sends JavaScript evaluation commands, and Chrome returns results as JSON. There is no embedded browser — Lorca relies on an already-installed Chrome or Chromium binary, which keeps the library dependency to a few hundred lines of Go code.
Self-Hosting & Configuration
- Add Lorca to your Go project with
go get github.com/zserge/lorca - Chrome or Chromium must be installed on the target machine
- Set window dimensions and position via the New() constructor parameters
- Bundle HTML, CSS, and JS assets into the Go binary using embed or a packing tool
- Cross-compile the Go binary for Windows, macOS, and Linux as usual
Key Features
- Entire library is under 1000 lines of Go with zero CGo dependencies
- Bidirectional Go-to-JavaScript function binding for seamless interop
- Window management including resize, fullscreen, and close detection
- Evaluate arbitrary JavaScript expressions and retrieve typed results
- No external build tools or bundlers required beyond the Go toolchain
Comparison with Similar Tools
- Electron bundles its own Chromium and Node.js, resulting in 150 MB+ apps; Lorca reuses the system Chrome
- Tauri pairs Rust with the system webview; Lorca pairs Go with the system Chrome
- Wails is a more full-featured Go desktop framework with build tooling and native bindings
- go-app compiles Go to WebAssembly for progressive web apps; Lorca runs native Go on the backend
- Carlo by Google followed a similar Chrome DevTools Protocol approach in Node.js but is now archived
FAQ
Q: What happens if Chrome is not installed? A: Lorca will return an error at startup. You can detect this and prompt the user to install Chrome or Chromium.
Q: Can I distribute the app without requiring Chrome? A: You would need to bundle a Chromium binary alongside your executable, which increases the distribution size significantly.
Q: Is Lorca suitable for production applications? A: Lorca works well for internal tools, utilities, and lightweight desktop apps. For complex production apps, consider Wails or Tauri which offer more features.
Q: Does Lorca support multiple windows? A: Each lorca.New() call creates an independent window. You can manage multiple windows from a single Go process.