hotwire-golang-website

This project provides some working examples using Go the hotwire/turbo library published by basecamp. This is based on a great post about Hotwire: HTML Over The Wire by @delitescere.

Overview

This service illustrates how to use turbo to enable updates to a website using primarily service side code.

  1. Uses html/template for views.
  2. Uses echo library to simplify routing.
  3. Uses a CDN to host all css / JS libraries base.html.
  4. Uses esbuild to automatically bundle JS assets on startup using echo-esbuild-middleware to serve them.

Hotwire Turbo

In this site I have implemented:

  1. Turbo Drive
  2. Turbo Frames
  3. Turbo Streams with Server Sent Events (SSE) and WebSockets
  4. stimulus

Most of the server side logic is in hotwire.go.

Prerequisites

  • Go 1.13 or later with support for Go Modules, used to build the service.
  • Node.js 12 or later, which is only used to install our asset building dependencies.

Running

To get this project running you need to setup some certificates, in my case I use https://github.com/FiloSottile/mkcert and there is a target in the makefile.

make certs

To start the service just run.

make start

For development you can use the following command, this will check for code updates and restart the service.

make watch

The service should be listening on https://hotwire.localhost:9443/

License

This application is released under Apache 2.0 license and is copyright Mark Wolfe.

GitHub

https://github.com/wolfeidau/hotwire-golang-website