https://github.com/apis/go-htmx-post-css-example
Example CRUD Web application written in Go, HTMX, PostCSS
https://github.com/apis/go-htmx-post-css-example
go-template golang htmx postcss vite
Last synced: 2 months ago
JSON representation
Example CRUD Web application written in Go, HTMX, PostCSS
- Host: GitHub
- URL: https://github.com/apis/go-htmx-post-css-example
- Owner: apis
- License: mit
- Created: 2024-12-20T15:16:21.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-07-02T17:56:54.000Z (12 months ago)
- Last Synced: 2025-07-02T18:26:03.676Z (12 months ago)
- Topics: go-template, golang, htmx, postcss, vite
- Language: Go
- Homepage:
- Size: 212 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-htmx-post-css-example
## Example CRUD Web application written in Go, HTMX, PostCSS
This is example Web application which is using [HTMX](https://htmx.org/) Javascript frontend library and
framework-less CSS generated with [PostCSS](https://postcss.org/). Server side rendering done with [Go HTML
templates](https://pkg.go.dev/html/template) on backend.
Application builds single executable with all frontend code and templates embedded into it.
## Change History
* v0.1 - Initial implementation.
* v0.2 - Set of refactorings. Reduced payload and handling for some of the HTML actions. Also added dynamic UI button blocking in edit mode. Updated HTMX to v2.
## Highlights
### Frontend dependencies
* [HTMX](https://htmx.org/) is a JavaScript library that streamlines web development by enabling you to define page behavior using HTML attributes and server-side logic, reducing the reliance on client-side JavaScript.
* [Vite](https://vite.dev) is a frontend tooling framework.
* [PostCSS](https://postcss.org/) plug-ins toolchain for consistent CSS styling and reducing assets size.
### Server side Go dependencies
* [Go HTML templates](https://pkg.go.dev/html/template) for server side rendering
* [Chi](https://github.com/go-chi/chi) HTTP server
* [Zerolog](https://github.com/rs/zerolog) for logging
Code in this project partially based on this [repo](https://github.com/jritsema/go-htmx-tailwind-example).
Thanks a lot to an author ❤️ it was solid starting point for my HTMX Go trip! All CRUD models and Go HTML templates were
shamelessly taken from there.
## Screenshot

## Build instructions
```console
cd web/frontend
npm i
npm run build
```
This should build your frontend assets into web/frontend/dist directory.
```console
cd ../..
go build .
```
This should build Go executable and embed assets and templates into it.
```console
./htmx-example
```
By default application runs on http://localhost:8080
```console
./htmx-example --Host 0.0.0.0 --Port 8081 --SimulatedDelay 1000
```
Optionally you can specify different host, port and simulate server side processing delay in milliseconds.