Search code examples
javascriptangularreactjspolymerweb-component

Web Components in Different Frameworks


I want to create Custom Web Components and use them in variety of frameworks like Angular, React and vanilla Javascript.

My question is Should I use Polymer(or any other library) to create one or write down by extending "HTMLElement".

What are the differences.


Solution

  • If you want to develop Custom Elements with Polymer, and intergrate them with another framework, you'll need to understand internals of both the Polymer and the other framework(s) to make them work flawlessly together, especially for complex architecture. I guess it's a challenge.

    Also, you'll have to deal with the versions and compatibility between different framework versions. For exemple, if you develop a component with Polymer v3, il will be difficult to integrate it with Polymer v2, especially in a cross-browser ecosystem.

    Lastly, if you intend to distribute your Custom Elements, you can imagine the 2 constraints above will apply to the targeted developers too. As a React developer, I wouldn't like to have to import another (the Polymer) framework and polyfill to integrate some 3rd-party components.

    For theses reasons I would recomment to design Vanilla Custom Elements in order to interact with a highest number of web frameworks.