Exploring Custom Elements
To be able to bring Blazor into an existing Angular or React site we use a feature called CustomElements. It was introduced as an experimental feature in .NET 6 and is now part of the framework in .NET 7.
The idea is to be able to create parts of your site in Blazor without having to go fully over to Blazor.
For this feature to work we need to have an ASP.NET backend or manually make sure the _framework files are available. This is so that we can serve the Blazor framework files we need to get it running.
There are two ways of running CustomElements we can run it as Blazor WebAssembly or as Blazor Server.
Since we are adding Blazor to a client framework like React or Angular I think the most relevant example is to run it as Blazor WebAssembly, therefore the samples in these first sections will be for Blazor WebAssembly.
In the GitHub repo, there is a folder called CustomElements
, in that folder, you will find the code for the projects we will see sample code...