News for hackers. Stuff that matters.
Re:Ask HN: Simplest stack to build web apps in 2021? by ASalazarMX on Monday November 22, 2021 @05:42PM (#29312459)
Wait, this looks and feels like a very pragmatic way of making modern websites. How has this not become more popular? What are its cons?
Re:Ask HN: Simplest stack to build web apps in 2021? by mamcx on Monday November 22, 2021 @05:58PM (#29312619)
> What are its cons?

Is very pragmatic. That means your whole investment in the arcane ways of JS are dust. Not hipster at all.

---

More seriously, Is of little issues here. You setup and it works, so is not something that lead to "generate content" like other setups.

I found only a significant issue (to me) (https://github.com/bigskysoftware/htmx/issues/596) but then I do something that have never done in long time with a JS library: I poke into the source and fix it myself. Far easier than expected! (ie: The code is plain!)

Re:Ask HN: Simplest stack to build web apps in 2021? by boyter on Monday November 22, 2021 @06:10PM (#29312730)
You return HTML from your "api" endpoint's is the biggest opposition I have found. Can mean additional work when you do want to switch to JSON, as the endpoints end up not being very reusable.

I quite like HTMX myself, although I consider it a tool you use to enhance websites and not something you use to build full blown web apps.

Re:Ask HN: Simplest stack to build web apps in 2021? by deniz-a on Monday November 22, 2021 @06:29PM (#29312844)
You don't return HTML from API endpoints, you return it from your UI endpoints. You could reuse those for JSON with content negotiation, or have a frontend server+backend server setup where the backend server is also a public API, or some other solution.
Re:Ask HN: Simplest stack to build web apps in 2021? by boyter on Monday November 22, 2021 @06:35PM (#29312891)
Semantics over the name aside, you end up returning small chunks of HTML from newly defined routes that are only useful for your HTMX frontend, hence my usage of API as the interface really only makes sense to the machine and not the user without the rest of the page content.

Yes you could inspect the headers and such to determine what type to return, but the core problem remains, that the HTML in those is not reusable whereas as JSON would be.

How much overhead this is for you depends on your design of course, but it does mean some work might potentially be wasted if you go down the full SPA application later and even if not changing layouts and such might be a pain.

Re:Ask HN: Simplest stack to build web apps in 2021? by recursivedoubts on Monday November 22, 2021 @07:21PM (#29313219)
Re:Ask HN: Simplest stack to build web apps in 2021? by animesh on Tuesday November 23, 2021 @03:23AM (#29315730)
Thanks for HTMX and your essays. Today I was reading HTMX documentation on what to do when we design API-first for a particular project but don't want any of the frontend magic aka SPA. I found immediately that I need to use both json_enc and client-side-templates extensions. Hope I am on the right path.
Re:Ask HN: Simplest stack to build web apps in 2021? by recursivedoubts on Tuesday November 23, 2021 @08:27AM (#29317507)
hi animesh, that would only be the case if you are trying to retrofit htmx on top of an existing JSON API

if it is greenfield development, it is much better to simply return SSR HTML and avoid that complexity

you can join the discord for more immediate help:

https://htmx.org/discord

Re:Ask HN: Simplest stack to build web apps in 2021? by animesh on Tuesday November 23, 2021 @10:42AM (#29319102)
That makes sense. I didn't think about it that way, but traditional MVC views would do just as well I guess for greenfield work.
Re:Ask HN: Simplest stack to build web apps in 2021? by ASalazarMX on Monday November 22, 2021 @08:49PM (#29313755)
> Semantics over the name aside, you end up returning small chunks of HTML from newly defined routes that are only useful for your HTMX frontend, hence my usage of API as the interface really only makes sense to the machine and not the user without the rest of the page content.

Web2py (being phased out by py4web which I haven't tried) made that very easy. If your api is accessed as api/hello.html, it can return HTML. According to the extension, hello.json, hello.csv, hello.txt, hello.pdf, etc. can return the adequate content.

Of course you can always return JSON regardless of the extension, but I found the same endpoints serving different formats very convenient.