Adding web components to a Blazor site
We have looked at adding Blazor to an existing Angular, React, and even MVC/Razor Pages site.
But sometimes, that perfect library you love to use might not have a Blazor counterpart. We know that we can make a JavaScript interop and build it ourselves, but can we also use Angular and React libraries from Blazor?
We have two options here; either we can convert our site into an Angular/React site and use those examples, or we can convert the JavaScript library into a web component and use it from Blazor.
Until now, we haven’t used npm or anything like that because, in most cases, we don’t need it. But now we are mixing technologies, and for that, npm is the easiest way. npm
is outside the scope of this book, so I will not go into any details about it.
How to convert Angular/React or anything else into a web component is also outside the scope of this book.
The project is called BlazorProject
.
We can browse...