DevInstance.BlazorToolkit 10.1.0

dotnet add package DevInstance.BlazorToolkit --version 10.1.0
                    
NuGet\Install-Package DevInstance.BlazorToolkit -Version 10.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DevInstance.BlazorToolkit" Version="10.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevInstance.BlazorToolkit" Version="10.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DevInstance.BlazorToolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevInstance.BlazorToolkit --version 10.1.0
                    
#r "nuget: DevInstance.BlazorToolkit, 10.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DevInstance.BlazorToolkit@10.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevInstance.BlazorToolkit&version=10.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DevInstance.BlazorToolkit&version=10.1.0
                    
Install as a Cake Tool

NuGet

Blazor Toolkit

Blazor Toolkit is a comprehensive set of tools designed to enhance the development of Blazor applications. It provides a suite of utilities and services that streamline common tasks, allowing developers to focus on building rich, interactive web applications.

Features

  • Network Communication Tools: Simplify network operations such as making REST API calls. BlazorToolkit offers easy-to-use methods for handling HTTP requests and responses, reducing boilerplate code and potential errors.

  • Middleware Services: Implement middleware logic as services to abstract complex processes from the UI layer. This promotes a clean separation of concerns, making your application more modular and maintainable.

  • Form Validators: Integrate robust form validation mechanisms to ensure data integrity. The toolkit includes flexible validators that can be easily applied to your forms, providing immediate feedback to users and enhancing the overall user experience.

Installation

Blazor Toolkit package is available on NuGet (https://www.nuget.org/packages/DevInstance.BlazorToolkit/) and can be installed using the following command:

Power shell:

dotnet add package DevInstance.BlazorToolkit

Package manager:

Install-Package DevInstance.BlazorToolkit

Examples

Create a new Blazor WebAssembly project. Add new service class EmployeeService.cs and register it in Program.cs. Add new razor component Home.razor and inject EmployeeService into it. Use IServiceExecutionHost interface to handle service execution state.

EmployeeService.cs:

// Services are registered with Scoped lifetime by default
[BlazorService]
public class EmplyeeService
{
    IApiContext<EmployeeItem> Api { get; set; }

    public EmplyeeService(IApiContext<EmployeeItem> api)
    {
        Api = api;
    }

    public async Task<ServiceActionResult<ModelList<EmployeeItem>?>> GetItemsAsync(int? top, int? page)
    {
        return await ServiceUtils.HandleWebApiCallAsync(
            async (l) =>
            {
                var api = Api.Get();
                if (top.HasValue)
                {
                    api = api.Top(top.Value);
                }
                if (page.HasValue)
                {
                    api = api.Page(page.Value);
                }
                return await api.ListAsync();
            }
        );
    }
}

Service Lifetimes: BlazorToolkit supports all DI service lifetimes:

// Scoped - instance per request/scope (default)
[BlazorService]
public class MyService { }

// Singleton - single instance for the entire application
[BlazorService(ServiceLifetime.Singleton)]
public class CacheService { }

// Transient - new instance for each injection
[BlazorService(ServiceLifetime.Transient)]
public class TemporaryService { }

Register service in DI container in Program.cs: Program.cs:


static async Task Main(string[] args)
{
    ...
    builder.Services.AddBlazorServices();
    ...
}

Add new razor component Home.razor and inject EmployeeService into it. Use IServiceExecutionHost interface to handle service execution state. BlazorToolkitPageLayout implement all necessary states like loading and error handling.

Home.razor:

@page "/"
@using DevInstance.BlazorToolkit.Components
@using DevInstance.BlazorToolkit.Services
@using DevInstance.EmployeeList.Client.Services
@using DevInstance.EmployeeList.Model
@using DevInstance.WebServiceToolkit.Common.Model

@layout BlazorToolkitPageLayout
<PageTitle>Home</PageTitle>

Welcome to your new app.

<ul>
@if (employees != null)
{
    @foreach (var employee in employees.Items)
    {
        <li>@employee.Name</li>
    }
}
</ul>

@code {

    [Inject]
    EmployeeService Service { get; set; }

    [CascadingParameter]
    public IServiceExecutionHost? Host { get; set; }

    private ModelList<EmployeeItem> employees = null;

    protected override async Task OnInitializedAsync()
    {
        await Host.ServiceReadAsync(() => Service.GetItemsAsync(null, null, null), (e) => employees = e);
    }
}

See more comprehensive example in DevInstance.BlazorToolkit.Samples project.

License

BlazorToolkit is licensed under the MIT License. You are free to use, modify, and distribute this software in accordance with the terms of the license.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.0 62 1/21/2026
10.0.1 71 1/20/2026
10.0.0 282 11/11/2025
9.2.4 133 11/7/2025
9.2.3 179 10/8/2025
9.2.1 174 10/8/2025
9.2.0 117 10/3/2025
9.1.3 178 9/9/2025
9.1.2 146 7/28/2025
9.1.0 197 4/23/2025
9.0.1 194 3/19/2025
9.0.0 185 3/19/2025
8.3.5 175 3/19/2025
8.3.4 180 3/19/2025
8.3.3 115 3/15/2025
8.3.2 122 1/23/2025
8.3.1 127 1/23/2025
8.2.0 131 1/23/2025
8.0.1 168 12/9/2024
8.0.0 151 12/6/2024