Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Returning partial HTML from endpoints is the whole point of htmx. If your endpoint returns json and you’re trying to convert that to HTML to use with htmx, don’t bother - just use another “traditional” Js framework.

I highly recommend the “building hypermedia systems” book (free at https://hypermedia.systems/) so you can understand the HTML/ hypermedia architecture of which htmx is a key component and how it’s meant to be used.



Thanks, will take a look at the book. Your points make sense, but having an extension dedicated to this made me think returning JSON may be ok.


If you have an endpoint that returns json and you can’t change for legacy, historical, compliance reasons, it might make some sense to integrate with an application that uses htmx the way it was intended and only needs that one weird legacy endpoint returning json to be converted to HTML client side. That sounds like the use case for that extension - the other explanation is someone wanting to jump on the htmx bandwagon without understanding the philosophy, and so trying to keep returning json, converting to HTML on the client and then trying to shoehorn this into a hypermedia architecture :)


> just use another “traditional” Js framework

Or don't use a framework at all. It's easy enough to convert JSON to HTML — you only need a few lines of JS.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: