DynamicHead.Blazor 1.0.0

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

🧠 DynamicHead.Blazor

Dynamic, component-driven <head> management for Blazor

Build NuGet NuGet Downloads License


πŸš€ Overview

DynamicHead.Blazor brings true dynamic head management to Blazor.
Unlike Blazor’s built-in <HeadOutlet> and <HeadContent>, this library allows any component to declaratively add, update, or remove <head> content β€” such as <title>, <meta>, or <link> tags β€” without overwriting others.


πŸ’‘ Why DynamicHead.Blazor?

Blazor’s built-in head management works only at the page level, and each <HeadContent> instance overwrites the previous one.

Limitation (Blazor’s built-in) Solved by DynamicHead.Blazor
Only page-level head content βœ… Any component can register head content
Each <HeadContent> overwrites previous βœ… All content merges dynamically
No automatic cleanup βœ… Automatically unregisters on dispose
No runtime updates βœ… Dynamically re-renders live
No parallel or nested support βœ… Works in any nested component

✨ Features

  • βš™οΈ Works with Blazor WebAssembly and Blazor Server
  • πŸ”„ Automatically adds and removes head elements
  • 🧠 Updates dynamically as component content changes
  • 🧱 Lightweight, no external dependencies
  • πŸ§ͺ Fully unit-tested (NUnit + bUnit + Moq)

πŸ“¦ Installation

Install from NuGet:

dotnet add package DynamicHead.Blazor

βš™οΈ Setup (WebAssembly Example)

Program.cs

using DynamicHead.Blazor;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

// Register the DynamicHead service
builder.Services.AddDynamicHead();

// Mount your app and the DynamicHeadOutlet
builder.RootComponents.Add<App>("#app");

// 🧠 Add DynamicHeadOutlet to the document head
builder.RootComponents.Add<DynamicHeadOutlet>("head::after");

await builder.Build().RunAsync();

πŸ’‘ head::after ensures the outlet is rendered directly inside the <head> element,
just like Blazor’s built-in <HeadOutlet> β€” but this version dynamically merges updates.


🧠 Usage

Use <DynamicHeadContent> anywhere in your app β€” even inside nested components:

@page "/about"

<DynamicHeadContent>
    <title>About – MyApp</title>
    <meta name="description" content="Learn more about MyApp." />
    <link rel="stylesheet" href="about.css" />
</DynamicHeadContent>

<h1>About</h1>

βœ… When this component renders:

  • Its content is registered in the shared head service
  • <DynamicHeadOutlet> re-renders the document <head>
  • When it’s disposed (navigated away), the content is automatically removed

🧠 Comparison

Feature Blazor <HeadContent> DynamicHead.Blazor
Nested components ❌ βœ…
Multiple fragments ❌ Overwrites βœ… Merges
Auto cleanup ❌ βœ…
Runtime updates ⚠️ Limited βœ… Full
Works with head::after βœ… βœ…

πŸ§ͺ Testing

DynamicHead.Blazor is fully covered by automated tests using:


πŸ“„ License

MIT Β© 2025 Simon Liebers

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.0 146 10/25/2025
0.0.4 132 10/25/2025
0.0.2 123 10/25/2025
0.0.1 122 10/25/2025