RossWright.MetalCore.Blazor 2026.1.1

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

Ross Wright's Metal Core Blazor Library

Copyright (c) 2023-2026 Pross Co.

Table of Contents


Services

IBrowserLocalStorage

IBrowserLocalStorage provides async access to the browser's localStorage API via JavaScript interop. All methods return ValueTask so they integrate naturally with await in Razor components.

// Store and retrieve a value
await localStorage.Set("theme", "dark");
var theme = await localStorage.Get("theme");

// Remove one key or clear everything
await localStorage.Remove("theme");
await localStorage.Clear();
Method Description
Set(string key, string value) Writes or overwrites value under key in localStorage
Get(string key) Returns the stored string, or null if the key does not exist
Remove(string key) Deletes the entry for key; no-op if the key is absent
Clear() Removes all entries from localStorage

IJsScriptLoaderService

IJsScriptLoaderService lazily loads external JavaScript files via interop, ensuring each script is injected only once per application lifetime.

// Load a script; subsequent calls for the same path are no-ops
await jsLoader.EnsureLoaded("/js/chart.min.js", "Chart");

// Optionally supply a hash for cache-busting
await jsLoader.EnsureLoaded("/js/chart.min.js", "Chart", fileHash: "abc123");
Method Description
EnsureLoaded(string path, string existenceObject, string? fileHash = null) Injects <script src="path"> if existenceObject is not already defined on window; fileHash is appended as a query-string cache-buster

IServiceCollection Extensions

Method Lifetime Description
AddBrowserLocalStorage() Transient Registers IBrowserLocalStorage for injection into components and services
AddJsScriptLoader() Singleton Registers IJsScriptLoaderService; singleton lifetime ensures each script is loaded at most once
builder.Services.AddBrowserLocalStorage();
builder.Services.AddJsScriptLoader();

App Builder Fluent Syntax

MetalCore provides extension methods on WebAssemblyHostBuilder and WebAssemblyHost that enable a single fluent chain from CreateDefault(args) through to RunAsync(), eliminating the intermediate variable assignments that standard WASM startup requires.

RunAsync(butFirst:) accepts an async delegate that runs after the host is built but before it starts. This is the right place to pre-load services — for example, fetching content or initializing state — before the first Blazor component render.

var app = WebAssemblyHostBuilder
    .CreateDefault(args)
    .AddRootComponents(_ => _.Add<App>("#app"))
    .AddMetalInjection(_ => _.ScanThisAssembly())
    .AddServices(_ => _.AddMudServices())
    .Build()
    .RunAsync(butFirst: async host => {
        await host.Services
            .GetRequiredService<IContentService>()
            .Initialize();
    });

WebAssemblyHostBuilder

Method Description Example
AddRootComponents(Action<RootComponentMappingCollection>) Fluent wrapper for registering Blazor root components builder.AddRootComponents(r => r.Add<App>("#app"))
AddServices(Action<IServiceCollection>) Fluent wrapper for registering DI services on the WASM host builder builder.AddServices(s => s.AddScoped<IFoo, Foo>())
UseApp(Action<WebAssemblyHost>) Post-build configuration callback on the built host builder.UseApp(h => ...)
RunAsync(Func<WebAssemblyHost, Task>) Runs an async initialization step before starting the WASM host builder.RunAsync(async h => await h.InitAsync())

Installation

dotnet add package RossWright.MetalCore.Blazor

Or add directly to your project file:

<PackageReference Include="RossWright.MetalCore.Blazor" Version="*" />

Note: IBrowserLocalStorage and IJsScriptLoaderService require a live browser JavaScript context. They are not suitable for server-side Blazor or SSR rendering modes.


See Also

Package Purpose
RossWright.MetalCore Core extensions, utilities, options builders, load logging, exceptions, signing
RossWright.MetalCore.Data Entity Framework extensions, GeoCoder, database timing interceptor
RossWright.MetalCore.Server ASP.NET Core messaging contracts, SMTP email service
RossWright.MetalCore.Populi Zero-dependency test-data generator: names, addresses, emails, coordinates, dates, prices, and lorem ipsum

License

All Ross Wright Metal Libraries including this one are licensed under Apache License 2.0 with Commons Clause.

You are free to:

  • Use the libraries in any project (personal or commercial)
  • Modify them
  • Include them in products or services you sell

You may not:

  • Sell the libraries themselves (or any product/service whose primary value comes from the libraries)
  • Repackage them with minimal changes and sell them as your own standalone product

Full legal text: LICENSE.md

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 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 (2)

Showing the top 2 NuGet packages that depend on RossWright.MetalCore.Blazor:

Package Downloads
RossWright.MetalGuardian.Blazor

MetalGuardian client-side library for Blazor apps

RossWright.MetalNexus.Blazor

MetalNexus client-side library for Blazor apps

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.1.1 98 5/17/2026
2026.1.0 102 5/14/2026
2026.0.0 108 4/26/2026
10.0.12 159 3/10/2026 10.0.12 is deprecated because it is no longer maintained.
10.0.11 155 2/23/2026 10.0.11 is deprecated because it is no longer maintained.
10.0.10 152 2/16/2026 10.0.10 is deprecated because it is no longer maintained.
10.0.9 145 2/16/2026 10.0.9 is deprecated because it is no longer maintained.
10.0.8 153 2/16/2026 10.0.8 is deprecated because it is no longer maintained.
10.0.7 161 2/12/2026 10.0.7 is deprecated because it is no longer maintained.
10.0.6 150 2/12/2026 10.0.6 is deprecated because it is no longer maintained.
10.0.5 161 1/26/2026 10.0.5 is deprecated because it is no longer maintained.
10.0.4 162 1/24/2026 10.0.4 is deprecated because it is no longer maintained.
10.0.3 159 1/16/2026 10.0.3 is deprecated because it is no longer maintained.
10.0.2 159 1/11/2026 10.0.2 is deprecated because it is no longer maintained.
10.0.1 157 1/10/2026 10.0.1 is deprecated because it is no longer maintained.
10.0.0 170 1/9/2026 10.0.0 is deprecated because it is no longer maintained.
8.5.3 180 1/11/2026 8.5.3 is deprecated because it is no longer maintained.
8.5.2 187 1/11/2026 8.5.2 is deprecated because it is no longer maintained.
8.5.1 188 1/10/2026 8.5.1 is deprecated because it is no longer maintained.
8.5.0 182 1/10/2026 8.5.0 is deprecated because it is no longer maintained.
Loading failed

[2026.1.1] - 5/17/2026
- Minor Fixes, additional Unit Tests and documentation.

[2026.1.0] - 5/13/2026
- Minor Fixes, additional Unit Tests and documentation.

[2026.0.0] - 4/26/2026
- Initial public release

** Prior versions released of this library were private and not intended for public use. Use version 2026.0.0 or later.**