If you expect end users to regularly generate components for endpoints neither you nor they control, I think htmx is a poor match for your use case. Can you generate a vanilla web component that uses fetch instead?
Web Development
Welcome to the web development community! This is a place to post, discuss, get help about, etc. anything related to web development
What is web development?
Web development is the process of creating websites or web applications
Rules/Guidelines
- Follow the programming.dev site rules
- Keep content related to web development
- If what you're posting relates to one of the related communities, crosspost it into there to help them grow
- If youre posting an article older than two years put the year it was made in brackets after the title
Related Communities
- !html@programming.dev
- !css@programming.dev
- !uiux@programming.dev
- !a11y@programming.dev
- !react@programming.dev
- !vuejs@programming.dev
- !webassembly@programming.dev
- !javascript@programming.dev
- !typescript@programming.dev
- !nodejs@programming.dev
- !astro@programming.dev
- !angular@programming.dev
- !tauri@programming.dev
- !sveltejs@programming.dev
- !pwa@programming.dev
Wormhole
Some webdev blogs
Not sure what to post in here? Want some web development related things to read?
Heres a couple blogs that have web development related content
- https://frontendfoc.us/ - [RSS]
- https://wesbos.com/blog
- https://davidwalsh.name/ - [RSS]
- https://www.nngroup.com/articles/
- https://sia.codes/posts/ - [RSS]
- https://www.smashingmagazine.com/ - [RSS]
- https://www.bennadel.com/ - [RSS]
- https://web.dev/ - [RSS]
I think I should clarify: This isn't a public library (yet). It's a system I'm creating in our company for usage within our products.
I thought about web components and actually created a few. But this hypermedia approach with HTMX is much simpler to develop and maintain, and since some of the components are very heavy, the server side rendering takes load off of clients and makes complex renderings possible.
Can you elaborate why do you think HTMX doesn't fit this usage? With webcomponents, the flow will be like this:
- Client fetch data from source
- Client render the data within tge component
With this hypermedia approach the flow looks like this
- The client requests component with data from source from server
- Server fetches the data, (possibly validates it)
- Server renders the component
- Server sends component to client
For in your company and only for usage with your products, this approach seems very reasonable. The trouble with htmx is that it uses the dom to manage state, so if the endpoint you call serves a script tag that loads (say) a cryptominer, all your end users are gonna be mining crypto. It's hard to imagine a company product serving malicious content that hijacks the browser of their own users, so I thinks you're safe here.
Good to hear that.
I'm also approaching it with a sort of zero trust security model. Everything, in and out is validated and sanitized. Especially Html injection and XSS.
This HTMX article on security says it’s not ok to call HTMX with external sources.
Where does it say that? It says “Only call routes you control”. As I understood you, you do control those routes.
Hypermedia APIs (i.e. HTML) are specific to the layout of your application, so there is almost never any reason you’d want to insert someone else’s HTML into your page. All you have to do is make sure you only call your own routes (htmx 2 will actually disable calling other domains by default).
Although I do control the routes, its seems like it's not common. One way is a reverse proxy so the component server is forwarded on /components path on the client. So the client can still call relative routs.