This is a simple chat app which shows how to use Go with Hotwire.


  • Messages from another user are received via Turbo Streams over a websocket connection.
  • A stimulus controller is used to clear the message form.
  • The application can work without JavaScript


You need to have go and npm installed.

Then run:

go get -u
git clone
cd chat-hotwire-go
npm install
npm run dev

After the above just run air, to start the webapp with hot reloading.

Note: The generated dist/main.css file is rather large now at ~6MB, but don’t worry this is only because every possible class of tailwind is included (there are many), once you build for production only ~4KB of CSS is left.

If you want to also rebuild the JS and CSS on change run npm run watch in a separate terminal session.

To build for production run npm run prod and then go build.

This project uses:

  • html/template, a html templating library included in the stdlib of Go
  • Echo, a Go web framework
  • Hotwire a new approach from Basecamp for writing modern web applications without much JavaScript
  • tailwindcss, makes HTML look nice
  • webpack, for packing JS and CSS into single files, with minimization enabled, setup to extract CSS to a seperate file
  • Air, for hot reloading Go code and templates on change.