<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn" -->

---
title: Building a Web App with Go and HTMX – Haseeb Majid
description: A back-end engineer walks through his personal stack for building web apps without heavy JavaScript frameworks: Go plus HTMX for server-driven UI updates,...
canonical: https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building a Web App with Go and HTMX – Haseeb Majid | daily.dev
og:description: A back-end engineer walks through his personal stack for building web apps without heavy JavaScript frameworks: Go plus HTMX for server-driven UI updates,...
og:url: https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn
og:image: https://api.daily.dev/og/posts/6lokG7TRN.png
og:image:alt: Building a Web App with Go and HTMX – Haseeb Majid
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Web App with Go and HTMX – Haseeb Majid

**[YouTube](https://daily.dev/sources/youtube)** · 54 min read · 6 upvotes · 0 comments

## Summary

A back-end engineer walks through his personal stack for building web apps without heavy JavaScript frameworks: Go plus HTMX for server-driven UI updates, Templ for fully-typed HTML templating with LSP support, and SQLC for handwritten, type-safe SQL queries. He covers HTMX attributes like hx-post, hx-target, hx-trigger, hx-push-url, out-of-band swaps, and redirect handling, plus dev tooling (Air for hot reload, Task for task running, Nix for reproducible dev shells, Playwright's Go bindings for e2e testing). He argues this simpler stack is easier to reason about and easier for LLMs to generate and review than React or Svelte, while acknowledging HTMX isn't ideal when heavy front-end reactivity or separate front-end/back-end teams are involved. A Q&A covers WebSockets, authentication via cookies, and handling endpoints shared between full-page loads and HTMX fragment requests.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=lZ4EPkIngRc>

## Questions this post answers

### How do HTMX out-of-band swaps work for updating multiple parts of a page from one response?

Out-of-band (OOB) swaps let a server response update multiple unrelated elements on a page at once, even outside the element targeted by hx-target. The response includes separate HTML snippets each carrying an id, and HTMX matches each snippet to the existing element with that id and swaps it in, so a single request can update a form, a toast notification, and other unrelated components simultaneously without returning the whole page.

_See how developers are combining htmx and go patterns like this on daily.dev._

### How does SQLC generate type-safe Go code from raw SQL queries?

SQLC takes handwritten SQL queries plus a database schema (from migrations) and generates fully typed Go structs and query functions from them, configured via a YAML file specifying query and schema locations. Because the SQL is handwritten rather than produced by an ORM, developers can review exactly what queries run, avoiding hidden complex joins, while still getting compile-time type safety for query inputs and outputs.

_Developers weighing sqlc against orms for go projects can find more comparisons on daily.dev._

### Why does a normal HTTP redirect not work when using HTMX and how do you fix it?

A normal redirect response fails with HTMX because when a request originates from an HTMX attribute (like hx-post), HTMX expects HTML to swap into the target element rather than following a redirect, so it would render the entire login page inside a small form. The fix is to check for the HX-Request header on the server and, when present, respond with an HX-Redirect header instead of a standard redirect, telling HTMX explicitly to navigate the browser.

_Anyone debugging htmx redirect quirks can track similar gotchas and fixes on daily.dev._

## Similar posts on daily.dev

- [How I use HTMX with Go– Alex Edwards](https://daily.dev/posts/how-i-use-htmx-with-go-alex-edwards-yu7zybtpn) · Alex Edwards · 10 upvotes · 0 comments
- [Please Just Fucking Try HTMX](https://daily.dev/posts/please-just-fucking-try-htmx-ncu8zbk1v) · Lobsters · 21 upvotes · 3 comments
- [HTMX and Signals: Modern Frontend Without JavaScript Frameworks](https://daily.dev/posts/htmx-and-signals-modern-frontend-without-javascript-frameworks-fotyevidi) · SitePoint · 1 upvotes · 0 comments
- [A deep dive into HTMX](https://daily.dev/posts/a-deep-dive-into-htmx-uuhadafnq) · Flavio Copes · 1 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#golang](https://daily.dev/tags/golang), [#htmx](https://daily.dev/tags/htmx)

[View this post on daily.dev](https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building a Web App with Go and HTMX – Haseeb Majid","url":"https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn"},"datePublished":"2026-09-17T14:15:33.544Z","dateModified":"2026-09-17T14:16:13.637Z","description":"A back-end engineer walks through his personal stack for building web apps without heavy JavaScript frameworks: Go plus HTMX for server-driven UI updates,...","image":"https://i.ytimg.com/vi/lZ4EPkIngRc/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/lZ4EPkIngRc/sddefault.jpg","isAccessibleForFree":true,"articleSection":"YouTube","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"YouTube","logo":"https://media.daily.dev/image/upload/s--W5zMumpP--/f_auto/v1725350181/logos/youtube","url":"https://daily.dev/sources/youtube"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,golang,htmx","timeRequired":"PT54M","video":{"@type":"VideoObject","name":"Building a Web App with Go and HTMX – Haseeb Majid","description":"A back-end engineer walks through his personal stack for building web apps without heavy JavaScript frameworks: Go plus HTMX for server-driven UI updates,...","thumbnailUrl":"https://i.ytimg.com/vi/lZ4EPkIngRc/sddefault.jpg","uploadDate":"2026-09-17T14:15:33.544Z","duration":"PT54M","url":"https://api.daily.dev/r/6lokG7TRN","embedUrl":"https://www.youtube.com/embed/lZ4EPkIngRc"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"YouTube","item":"https://daily.dev/sources/youtube"},{"@type":"ListItem","position":3,"name":"Building a Web App with Go and HTMX – Haseeb Majid"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/building-a-web-app-with-go-and-htmx-haseeb-majid-6lokg7trn#faq","mainEntity":[{"@type":"Question","name":"How do HTMX out-of-band swaps work for updating multiple parts of a page from one response?","acceptedAnswer":{"@type":"Answer","text":"Out-of-band (OOB) swaps let a server response update multiple unrelated elements on a page at once, even outside the element targeted by hx-target. The response includes separate HTML snippets each carrying an id, and HTMX matches each snippet to the existing element with that id and swaps it in, so a single request can update a form, a toast notification, and other unrelated components simultaneously without returning the whole page. See how developers are combining htmx and go patterns like this on daily.dev."}},{"@type":"Question","name":"How does SQLC generate type-safe Go code from raw SQL queries?","acceptedAnswer":{"@type":"Answer","text":"SQLC takes handwritten SQL queries plus a database schema (from migrations) and generates fully typed Go structs and query functions from them, configured via a YAML file specifying query and schema locations. Because the SQL is handwritten rather than produced by an ORM, developers can review exactly what queries run, avoiding hidden complex joins, while still getting compile-time type safety for query inputs and outputs. Developers weighing sqlc against orms for go projects can find more comparisons on daily.dev."}},{"@type":"Question","name":"Why does a normal HTTP redirect not work when using HTMX and how do you fix it?","acceptedAnswer":{"@type":"Answer","text":"A normal redirect response fails with HTMX because when a request originates from an HTMX attribute (like hx-post), HTMX expects HTML to swap into the target element rather than following a redirect, so it would render the entire login page inside a small form. The fix is to check for the HX-Request header on the server and, when present, respond with an HX-Redirect header instead of a standard redirect, telling HTMX explicitly to navigate the browser. Anyone debugging htmx redirect quirks can track similar gotchas and fixes on daily.dev."}}]}
```

