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

I've never used htmx, primarily because I like the concept of "components" so much. (They serve two needs - standardizing larger blocks of UI and encapsulating them with an alternative interface, and providing islands of rich interactivity)

Is there any material on successfully combining htmx with web components? It doesn't look to me like the original design takes this possibility into consideration...

(note: at a surface glance it doesn't look to me like components are in conflict with hypermedia - one could treat them as a side channel that "enhances" the standard set of elements)



I use Unpoly and not HTMX but similar idea, what you do for components entirely is up to you.

My components look like this. The JS and CSS is included in the application's bundles. Ruby renders HTML on the server side.

  app/components/breadcrumbs
    - _breadcrumbs.scss
    - breadcrumbs_component.rb

  ...
  app/components/search_field
    - _search_field.scss
    - search_field_component.rb
    - search_field.js
    - selections.html.haml


I'm not sure if I've entirely grokked the idea of components, but can't you define them server-side? So write them as some template magic that creates the "inner HTML". Then you just need some HTMX to enable using the component in a richer way.

It's not really Web Components as specified, but iirc those are generally pretty much JS-dependent? But hypermedia's reliance on server side rendering means that you can just move this logic to the server.


Why wouldn't htmx work with web components? It just does asynchronous fetches and DOM swaps. Web components are just pieces of DOM. There should be absolutely no issue with them working together?




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

Search: