Search⌘ K

Creating a Razor Class Library

Explore how to create and test Razor class libraries in Blazor to build reusable components for multiple projects. This lesson guides you through creating a Razor class library project, adding it as a reference, and verifying component functionality within a Blazor application.

We can share components across projects by using a Razor class library. To create a Razor class library, we will use the Razor Class Library project template. We do this as follows:

  1. Right-click the solution and select the “Add, New Project” option from the menu.
  2. Enter “Razor Class Library” in the “Search for templates” textbox to locate the Razor Class Library project template:
Razor Class Library project template
Razor Class Library project template
  1. Select the “Razor Class Library” project template.
...