RepositoryGoESSpain
emarifer

emarifer/gofiber-templ-htmx

Go/Fiber🧬+</>Templ to-do list app with user login and HTMx-powered frontend.

142stars
16forks
0issues
1views

Go/Fiber🧬+</>Templ to-do list app with user login and HTMx-powered frontend (Demo)

A full-stack application using Golang's Fiber framework with session-based authentication. Once we are authenticated we can enter a view from which we can manage a list of tasks (list, update and delete). Requests to the backend are controlled by </>htmx (hypermedia only).

GitHub License Static Badge


[!NOTE] This application is an clone of this repository of mine (rust-axum-askama-htmx-todoapp), but made in Golang.


🤔 Explanation

The application allows us to perform a complete CRUD on the database, in this case SQLite3.

The DB stores both a table with the users and another table for each user's to-do. Both tables are related using a foreign key.

In this application we have used the Fiber framework, which, as it says in its documentation, is "an Express-inspired web framework". This makes creating web applications much easier for people coming from the world of JavaScript. Fiber is a Go web framework built on top of Fasthttp, the fastest HTTP engine for Go. It's designed to ease things up for fast development with zero memory allocation and performance in mind.

Authentication (via session) is done using built-in middleware. On the other hand, a dependency is also used to handle flash messages.

Finally, using the Fiber framework also allows us centralized error handling.


[!IMPORTANT] In this application, instead of using the html/template package (gofiber/template/html, specifically), we use the a-h/templ library. This amazing library implements a templating language (very similar to JSX) that compiles to Go code. Templ will allow us to write code almost identical to Go (with expressions, control flow, if/else, for loops, etc.) and have autocompletion thanks to strong typing. This means that errors appear at compile time and any calls to these templates (which are compiled as Go functions) from the handlers side will always require the correct data, minimizing errors and thus increasing the security and speed of our coding.

The use of </>htmx allows behavior similar to that of a SPA, without page reloads when switching from one route to another or when making requests (via AJAX) to the backend.

On the other hand, the styling of the views is achieved through Tailwind CSS and DaisyUI that are obtained from their respective CDNs. Likewise, the SweetAlert2 library is used, a substitute for javascript pop-up boxes. In the same way it is obtained from its respective CDN.

Finally, minimal use of _hyperscript is made to achieve the action of closing alerts when they are displayed and the action of showing/hiding the password in corresponding text input fields.

[!NOTE] This application is identical, although much more improved, to that of a previous repository of mine, which is developed in GoFiber-template/html instead of Templ templating language, as in this case.


🖼️ Screenshots:

Todo List Page with success alert & Sign Up Page with error alert:

  


Task update page & popup alert based on SweetAlert2:

  


Centralized handling of 404 & 500 errors:

  



👨‍🚀 Setup:

Besides the obvious prerequisite of having Go! on your machine, you must have Air installed for hot reloading when editing code.

Start the app in development mode:

$ air # This also compiles the view templates automatically / Ctrl + C to stop the application

Build for production (previously it is necessary to regenerate the templates with the templ generate command; see explanation below):

$ go build -ldflags="-s -w" -o ./bin/main . # ./bin/main to run the application / Ctrl + C to stop the application

[!TIP] In order to have autocompletion and syntax highlighting in VS Code for the Teml templating language, you will have to install the templ-vscode extension (for vim/nvim install this plugin). To generate the Go code corresponding to these templates you will have to install the templ CLI:

$ go install github.com/a-h/templ/cmd/templ@latest

[!TIP] And then regenerate the templates with the command:

$ templ generate # The `templ generate --watch` command will watch the project folder to regenerate them every time we make a change to its code.

[!TIP] Review the documentation on Templ installation and support for your IDE.


Happy coding 😀!!

Similar Projects

Discover other similar projects and AI models.

RepositoryGo
hrshadhin/fiber-go-boilerplate

🚀 Production-ready Golang based boilerplate application with Fiber web framework

101
Jul 1, 2024
RepositoryGo
ollama/ollama

Get up and running with Inkling, Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

188.9k
Dec 2, 2026
RepositoryGo
gofiber/fiber

⚡️ Express inspired web framework written in Go

40.4k
Dec 1, 2026
RepositoryGo
JioTV-Go/jiotv_go

Unlock the magic of JioTV across all your devices, without the need for the JioTV App. Crafted with love in Golang for a delightful blend of speed and efficiency! 🌟✨

766
Nov 25, 2026
RepositoryGo
donseba/go-htmx

Seamless HTMX integration in golang applications

601
Nov 5, 2026
RepositoryGo
emarifer/go-echo-templ-htmx

Go/Echo+Templ+Htmx: Full stack application using Golang's Echo framework & Templ templating language with user session management + CRUD to a SQLite database (To Do List) and HTMX in the frontend

298
Jun 19, 2024
RepositoryGo
indravscode/go-fiber-boilerplate

A boilerplate for building RESTful APIs using Golang, Fiber, and GORM PostgreSQL

222
Dec 13, 2025
RepositoryGo
samber/slog-fiber

🚨 Fiber middleware for slog logger

99
Nov 1, 2026
RepositoryGo
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

197.2k
Dec 2, 2026