StencilJS is a compiler for web components , meaning you will write your component using jsx and then the Stencil in the build process will generate a native web component with some more features like date binding , async redering, virtual DOM that will enrich the component's operation.
Creating components using purely the web components API is very verbose and generally difficult (for more complex components). In this way StencilJS comes with the proposal to facilitate the development of web components , bringing technologies already common in the world frontend as tsx for creating components to facilitate development.
The Ionic team created StencilJS to use in the new version of Ionic that is being developed using web components built with StencilJS. This way you can use StencilJS to create mobile applications using Ionic as well as any other web framework like Angular, React, Vue, etc.
StencilJS uses decorators to abstract the native features of web components , making it easier for the developer. Some decorators useful to develop a component:
-
@Prop
controls the assignment of values to the properties of the component.
-
@PropWillChange
and @PropDidChange
observes state changes in component properties.
-
@Event
emits custom events
-
@Listen
listen for native DOM events and custom events also.
All components built with Stencil are loaded lazy , that is, the components can be separated into different bundles build ). So if we have the a component in one bundle and the b component in another bundle a on your page will only load the bundle from the component and not the bundle / strong> as well. This greatly reduces the load time required to use the desired components.
StencilJS is not a framework , but rather a compiler for web components
StencilJS also adds polyfills of web components required for its components to function properly. Note that polyfills will be added as needed as per the support of each web browser .
See official documentation that can be accessed at official website .
See also the GitHub project .