DEV Community

Discussion on: On Using Web Component Libraries

 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

To literally answer your question: You probably can

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

But no, I actually did answer your question. Most applications that do anything interesting quickly start to look worse when written in svelte than if they were just built with web components.

To illustrate, here's just one example of an advantage: HTMLElement (or, more likely, any boilerplate-reducing wrapper you would use) is is a class, and on top of it one that shares the API of any other HTML element. This means you can use methods like querySelector & co. but you can also implement methods around the specific purpose of the component. Svelte, by contrast, only lets you trigger behaviour by changing state, or awkwardly passing closures around. Neither leads to readable code.