Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lu4p/chat-hotwire-go
This is a simple chat app which shows how to use Go with Hotwire.
https://github.com/lu4p/chat-hotwire-go
golang hotwire stimulusjs turbo websocket
Last synced: 30 days ago
JSON representation
This is a simple chat app which shows how to use Go with Hotwire.
- Host: GitHub
- URL: https://github.com/lu4p/chat-hotwire-go
- Owner: lu4p
- License: unlicense
- Created: 2021-01-11T21:58:18.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-11T13:28:06.000Z (over 3 years ago)
- Last Synced: 2024-06-21T15:48:14.492Z (5 months ago)
- Topics: golang, hotwire, stimulusjs, turbo, websocket
- Language: Go
- Homepage:
- Size: 220 KB
- Stars: 27
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chat-hotwire-go
This is a simple chat app which shows how to use Go with [Hotwire](https://hotwire.dev/).![demo](demo.png)
- Messages from another user are received via [Turbo Streams](https://turbo.hotwire.dev/reference/streams) over a websocket connection.
- A [stimulus](https://stimulus.hotwire.dev/) controller is used to clear the message form.
- The application can work without JavaScript## Setup
You need to have [go](https://golang.org/dl/) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) installed.Then run:
```sh
go get -u github.com/cosmtrek/air
git clone https://github.com/lu4p/chat-hotwire-go.git
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](https://pkg.go.dev/html/template), a html templating library included in the stdlib of Go
- [Echo](https://echo.labstack.com/), a Go web framework
- [Hotwire](https://hotwire.dev/) a new approach from Basecamp for writing modern web applications without much JavaScript
- [tailwindcss](https://tailwindcss.com/), makes HTML look nice
- [webpack](https://webpack.js.org/), for packing JS and CSS into single files, with minimization enabled, setup to extract CSS to a seperate file
- [Air](https://github.com/cosmtrek/air), for hot reloading Go code and templates on change.