First Steps with Blazor Client-Side
This article explains how to get the Telerik UI for Blazor components in your Blazor WebAssembly app and start using them quickly. You will create a new application from scratch, learn how to add the UI for Blazor components to a project, and finally, add a UI component to a view.
This article applies only to the Blazor WebAssembly Standalone App Visual Studio project template.
If you prefer the Blazor Web App template with WebAssembly render mode, then follow the tutorial about Blazor Web Apps.
This step-by-step tutorial starts with the basics and is suitable for first-time Blazor or Telerik component users. If you are already familiar with the Telerik license key, NuGet source, components, and Blazor in general, you may prefer the Telerik UI for Blazor Workflow Details article. It provides more setup options and suggests possible enhancements.
Prerequisites
To successfully complete the steps in this tutorial:
- Install a supported .NET version.
- Create a Telerik user account if you haven't one.
- Activate a Telerik UI for Blazor trial if you don't have a commercial license.
Step 0: Set Up Telerik Development Environment
The fastest way to set up your Telerik development environment is to use the Telerik CLI .NET tool. Run the following commands in your preferred command shell (Visual Studio Terminal, cmd, PowerShell, Bash, macOS Terminal, or other):
-
Install Telerik CLI
SHdotnet tool install -g Telerik.CLI -
Run the Telerik CLI
setupcommand:SHtelerik setup
The setup command performs multiple actions at once to configure your Telerik development environment:
- Log in to your Telerik account.
- Download a Telerik license key that includes all your licenses and trials.
- Configure a Telerik NuGet package source.
- Install MCP servers.
Step 1: Create a New Project
To create a new Blazor app:
- Оpen your preferred IDE or run the
dotnet new.NET CLI command. - Use the Blazor WebAssembly Standalone App project template.
Step 2: Install the Telerik UI for Blazor Components
Add the Telerik.UI.for.Blazor NuGet package to every project that will use the Telerik Blazor components.
Step 3: Enable the Blazor UI Components
To enable the Telerik UI for Blazor components, you must add several client-side dependencies to the application, include the required @using statements, add the TelerikRootComponent component, and register the Telerik Blazor service.
3.1. Add the Telerik UI for Blazor Client Assets
-
Add the
telerik-blazor.jsfile to thewwwroot/index.htmlfile as a static asset.HTML<head> . . . <script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js"></script> </head> -
Add a theme stylesheet as a static asset in the
index.htmlfile.HTML<head> . . . <link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" /> </head>
3.2. Include @using Statements
In the ~/_Imports.razor file, add the @using directives below. This configures the project to recognize the Telerik components in all files. You can register one or both icon namespaces, depending on the icon type you will be using.
_Imports.razor
@using Telerik.Blazor
@using Telerik.Blazor.Components
@using Telerik.SvgIcons
@using Telerik.FontIcons
3.3. Add the TelerikRootComponent
Use a single TelerikRootComponent component as a top-level component in the Blazor client-side app.
Add a <TelerikRootComponent> to the app layout file (by default, MainLayout.razor). Make sure that the TelerikRootComponent wraps all the content in the MainLayout.
MainLayout.razor
@inherits LayoutComponentBase
<TelerikRootComponent>
@* existing MainLayout.razor content here *@
</TelerikRootComponent>
You can learn more about the TelerikRootComponent purpose and usage in its dedicated documentation.
3.4. Register the Telerik Blazor Service
In the ~/Program.cs file of the client web application, register the Telerik Blazor service.
using ClientBlazorProject;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
// sample host builder for a WASM app, yours may differ
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// Register the Telerik services.
builder.Services.AddTelerikBlazor();
await builder.Build().RunAsync();
Now your project can use the Telerik UI for Blazor components.
Step 4: Add a Component to a View
The final step in this tutorial is to use a Telerik UI for Blazor component in a view and run it in the browser.
-
In the
~/Pages/Index.razorview, add aTelerikButtoncomponent.Home.razor
RAZOR<TelerikButton ThemeColor="@ThemeConstants.Button.ThemeColor.Primary" OnClick="@OnButtonClick">Say Hello</TelerikButton> <p>@HelloString</p> @code { private MarkupString HelloString { get; set; } private void OnButtonClick() { HelloString = new MarkupString($"Hello from <strong>Telerik UI for Blazor</strong> at {DateTime.Now.ToString("HH:mm:ss")}!" + "<br /> Now you can use C# to write front-end!"); } } -
Run the app in the browser. You should see something like this:

Well done! Now you have your first Telerik UI for Blazor component running in your Blazor app, showcasing the power of front-end development with Blazor.