I am trying to work out how to create a shared component library in Blazor. Basically i want to create my components once and then be able to use them in multiple UI projects.
Component library
I created a simple component library as follows
dotnet new blazorlib -n UsComponentLibrary.Lib
Created a component component1.razor
<h3>Component1 from lib</h3>
@code {
}
UI
I added a reference to the library in the ui project. edited the _host.chtml file to include it
@page "/"
@namespace UsComponentLibrary.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, UsComponentLibrary.Lib
Added it to one of the pages
@page "/counter"
hello
<Component1></Component1>
@code {
}
output
The only thing its displaying is Hello i am not getting the text from the component in the library. What am i missing? Its like the ui page can see the component but when I run it its not there.