This blog post will show how to create a Blazor application using the .NET command-line interface (CLI).
Blazor allows us to create interactive web applications that run C$ and ASP.NET code. With Blazor .NET, developers can leverage their existing skills and build modern and single-page applications(SPAs).
Create a Blazor App
To create a Blazor app using the CLI, make sure you have .NET 7 installed on your machine and run the following command.
dotnet new blazorserver -o BlazorApp -f net6.0
Run the following code to add a Blazor component to an existing application.
dotnet new razorcomponent -n BlazorApp -o Pages -f net6.0
Note that the name of a Blazor component must start with an uppercase character.
The -n option specifies the component’s name we are adding, and the -o specify the folder. The -f sets the .NET framework the application will be built with.