Getting familiar with Razor components
Everything is a Razor component in Blazor Wasm, including the application itself, which is defined as a root component. In the Program.cs
file, that root component is registered as follows:
builder.RootComponents.Add<App>("#app");
The App
type is from the App.razor
component (we cover how components work later), and the string "#app"
is a CSS selector. The wwwroot/index.html
file contains a <div id="app">Loading...</div>
element that is replaced by the Blazor App
component once the application is initialized. #app
is the CSS selector identifying an element that has an id="app"
attribute. The wwwroot/index.html
static file is the default page served to clients; it is your Blazor app starting point. It contains the basic HTML structure of the page, including scripts and CSS. And that’s how a Blazor application is loaded.
The App.razor
file defines a Router
component that...