Introducing a new desktop application stack for web developers who love HTML and CSS, but hate JavaScript! The WTH stack allows you to write a fully-featured desktop application using Go. With the WTH stack, you can bring your hypermedia-driven applications to the desktop. The WTH stack embraces the concept of HATEOAS and server-side-rendered UIs.
The WTH Stack
There are three components to the WTH Stack:
- Wails — a Go library for building cross-platform applications. This acts as the web renderer host and includes a built-in HTTP server which is used to serve the application's UI.
- Templ — a templating language based on Go for HTML and CSS. This powerful Go-based templating engine allows you to write server-generated HTML and CSS.
- HTMX — a small JavaScript library for declaratively adding interactivity to HTML elements. This library extends HTML to be a complete hypertext. It allows you to declaratively annotate your HTML elements with attributes to trigger HTTP requests and update the DOM with the HTML from the response.
What the Hell is This?
Currently, the best option for building HTML/CSS-based desktop applications is Electron with React, but that requires that you write JavaScript. Using JavaScript to render HTML client-side is slow, and thus the industry has been moving towards server-side rendering (SSR). Unfortunately, this move has left desktop applications behind because there's no server to handle rendering.
The WTH stack solves this problem by handling the HTTP requests made by your application using Wails. Wails allows you to provide a standard Go backend which your application UI can interact with as if it were over HTTP.
One major advantage of the WTH stack is that it allows backend-focused developers to build desktop applications using tools and techniques they are already familiar with. It also centralizes the application's state, logic, and rendering in a single place (the backend) which makes the frontend a true view layer (in the MVC sense).
Isn't This Kinda Cursed?
Yes.
How Do I Get Started?
There is a Wails template for this stack already: PylotLight/wails-htmx-templ-template, however you may find that it has a lot of complexity (Tailwind, Chi, etc.) that you don't need. It's very easy to rip that stuff out.