DEV Community

Discussion on: We Should Stop Hating Web Components

Collapse
 
nicozerpa profile image
Nico Zerpa (he/him)

I think one of the things that hold web components back is the lack of declarative programming.

Most frontend devs learned components through some UI framework or library that is declarative. Having components in Vanilla DOM but having to code them in an imperative style might feel like a step backwards for some people.

Also, some JS devs don't like using classes, and that's a problem because Custom Elements requires using them.

Collapse
 
theharshsingh profile image
Harsh Singh

Yeah i agree that Web Components API needs improvement but you can already use libraries like Hybrids.js or Switzerland.js for creating web components in "functional" way and completely avoid the use of classes.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

The collection of APIs we often call "web components" aren't really supposed to be a finished product; they provide low-level access to browser features that let you do almost everything you need, but at the expense of making the most common cases more cumbersome than necessary.

The point is that these APIs make it much easier to build your own declarative systems without having to bother re-implementing too many of the same features every time.

I personally don't even like frameworks like Vue or Svelte too much, because they're a bit too declarative for my taste, meaning I give up control over how data flows through the application. With web components I can build my own micro-framework with like 50 lines of code and continue building stuff on top of that instead.

Collapse
 
theharshsingh profile image
Harsh Singh

Yes Web Components were meant to be used in that way. You can either write your web components using vanilla js or you can use a collection of tiny helper libraries for performing different functions like routing and state management. and its not like there are no libraries available out there. there are over a dozen libraries just for adding the routing functionality in web components, but they are all either badly documented or lack any support from the community. i urge the Web Component community to come forward and start helping the newcommers and do more than being a Symbolic entity.