BlazorBlades 0.5.0

dotnet add package BlazorBlades --version 0.5.0
                    
NuGet\Install-Package BlazorBlades -Version 0.5.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="BlazorBlades" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorBlades" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="BlazorBlades" />
                    
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 BlazorBlades --version 0.5.0
                    
#r "nuget: BlazorBlades, 0.5.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 BlazorBlades@0.5.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=BlazorBlades&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=BlazorBlades&version=0.5.0
                    
Install as a Cake Tool

Blazor Blades

Nuget

TL;DR

Conveniently render strongly-typed Razor Components and Fragments via Minimal APIs

Try It

Add NuGet

> dotnet add package BlazorBlades

Add these to your Component.razor

  • Add @inherits BlazorBlade<Model>
  • Add @implements IMapEndpoints
  • Implement MapEndpoints() in @code{ } or Component.razor.cs
// MyComponent.razor
@inherits BlazorBlade<Model> // Generates @Model, Blade(), RenderAsync()
@implements IMapEndpoints // Provides MapEndpoints()

// Generated @Model Property 
<div>Hello @Model.Name !</div>

@code
{
  public static void MapEndpoints(IEndpointRouteBuilder app)
  {
    app.MapGet("/component", () => 
    {
      var model = new Model("Jason");

      // Strongly-Typed RazorComponentResult
      return MyComponent.Blade(model); 
    });

    app.MapGet("/fragment", async () =>
    {
        var message = "Developers, Developers, Developers!"

        // Inline Fragment Result
        return Results.Razor
        (
            @<div>
                Quote: @message
            </div>
        );
    });

    app.MapGet("/raw", (IServiceProvider services) => 
    {
      // Render Component      
      var html = await MyComponent.RenderAsync(services, new Model("Jason"));

      // Render Fragment
      var html = await HelperFragments.SayHello("Julia").RenderAsync()
      ...
    });
  }
}

Add app.MapEndpoints() to program.cs to map all IMapEndpoints components

var app = builder.Build();
...
app.MapEndpoints();
...

Demo

The sample web app in Components/Page.razor has several examples.

What

Blazor Blades is an experimental project inspired by RazorSlices, but built around Blazor .razor components instead of Razor .cshtml templates. It's aimed at devs looking for a .NET hypermedia workflow that is strongly typed end-to-end while keeping the benefits of Blazor components.

Why

I wanted a way to build HTML-first applications using Minimal APIs with:

  • Compile-time type safety for the data each rendered template requires
  • Template composition and reuse through components and functions
  • Locality of template, model, and endpoint code
  • Any Javascript library for interactivity (Datastar, Htmx, jQuery, etc.)

How

BlazorBlades lets a .razor component opt into generated capabilities:

  • @inherits BlazorBlade<TModel> provides a Static Component.Blade(model)
  • @implements IMapEndpoints provides a Static Component.RenderAsync(services, model)
  • app.MapEndpoints() automatically calls Component.MapEndpoints(app)

Two component marker interfaces and source generators are used to accomplish this:

BlazorBlades also makes working with RenderFragement easier with:

  • Results.Razor(fragment)
  • fragment.RenderAsync(services)
  • fragment.Blade()

Who

I'm Jason Barnes - Follow me: @vyrotek

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.
  • net10.0

    • No dependencies.

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
0.5.0 189 3/15/2026
0.4.0 139 3/12/2026
0.3.0 135 3/12/2026
0.2.0 135 3/10/2026
0.1.0 129 3/7/2026