Soenneker.Blazor.CallbackRegistry
11.0.1237
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Blazor.CallbackRegistry --version 11.0.1237
NuGet\Install-Package Soenneker.Blazor.CallbackRegistry -Version 11.0.1237
<PackageReference Include="Soenneker.Blazor.CallbackRegistry" Version="11.0.1237" />
<PackageVersion Include="Soenneker.Blazor.CallbackRegistry" Version="11.0.1237" />
<PackageReference Include="Soenneker.Blazor.CallbackRegistry" />
paket add Soenneker.Blazor.CallbackRegistry --version 11.0.1237
#r "nuget: Soenneker.Blazor.CallbackRegistry, 11.0.1237"
#:package Soenneker.Blazor.CallbackRegistry@11.0.1237
#addin nuget:?package=Soenneker.Blazor.CallbackRegistry&version=11.0.1237
#tool nuget:?package=Soenneker.Blazor.CallbackRegistry&version=11.0.1237
Soenneker.Blazor.CallbackRegistry
A scoped bridge for routing JavaScript events to typed, instance-specific .NET callbacks by ID.
Installation and registration
dotnet add package Soenneker.Blazor.CallbackRegistry
using Soenneker.Blazor.CallbackRegistry.Registrars;
builder.Services.AddBlazorCallbackRegistryAsScoped();
Register a callback
Register after the component's first render so JavaScript interop is available. Unregister component-owned IDs when the component is disposed.
@implements IDisposable
@inject IBlazorCallbackRegistry CallbackRegistry
@code {
private const string CallbackId = "orders:active";
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await CallbackRegistry.Register<OrderUpdated>(CallbackId, OnOrderUpdated);
}
private Task OnOrderUpdated(OrderUpdated update)
{
// Apply the update and refresh component state as needed.
return Task.CompletedTask;
}
public void Dispose() => CallbackRegistry.Unregister(CallbackId);
}
Registering the same ID again replaces its callback. IDs share the registry's DI scope, so use stable, collision-resistant names for independently rendered components. The stateful overload stores a state value with the callback:
await CallbackRegistry.Register<MyComponent, OrderUpdated>(
callbackId,
this,
static (component, update) => component.OnOrderUpdated(update));
Send an event from JavaScript
Import the package module using the application's base URI, then await sendToCallback so .NET deserialization or callback failures are observable by JavaScript:
const callbackRegistry = await import(new URL(
"_content/Soenneker.Blazor.CallbackRegistry/js/callbackregistryinterop.js",
document.baseURI));
await callbackRegistry.sendToCallback("orders:active", {
orderId: "2d8f1d42",
status: "shipped"
});
The payload is serialized in JavaScript and deserialized as the registered generic type in .NET. Keep payload types JSON-compatible. A missing ID is ignored; malformed JSON or a callback exception rejects the JavaScript promise.
IBlazorCallbackRegistry is scoped and owns the JavaScript bridge reference. Let DI dispose it. Do not manually dispose an injected registry while other components in the same scope may still use it.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Asyncs.Initializers (>= 11.0.140)
- Soenneker.Blazor.Utils.ModuleImport (>= 11.0.1944)
- Soenneker.Utils.Json (>= 11.0.2790)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Blazor.CallbackRegistry:
| Package | Downloads |
|---|---|
|
Soenneker.Maui.Blazor.Bridge
Seamlessly connects MAUI and Blazor, enabling smooth integration of native components into Blazor |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1254 | 136 | 11/19/2026 |
| 11.0.1253 | 85 | 11/19/2026 |
| 11.0.1252 | 81 | 11/19/2026 |
| 11.0.1251 | 83 | 11/19/2026 |
| 11.0.1250 | 79 | 11/19/2026 |
| 11.0.1249 | 83 | 11/19/2026 |
| 11.0.1248 | 83 | 11/18/2026 |
| 11.0.1247 | 81 | 11/18/2026 |
| 11.0.1246 | 87 | 11/18/2026 |
| 11.0.1242 | 87 | 11/18/2026 |
| 11.0.1241 | 99 | 11/18/2026 |
| 11.0.1240 | 131 | 11/16/2026 |
| 11.0.1239 | 113 | 11/16/2026 |
| 11.0.1238 | 106 | 11/15/2026 |
| 11.0.1237 | 106 | 11/15/2026 |
| 11.0.1236 | 96 | 11/15/2026 |
| 11.0.1235 | 104 | 11/15/2026 |
| 11.0.1234 | 117 | 11/15/2026 |
| 11.0.1233 | 115 | 11/15/2026 |
| 11.0.1232 | 117 | 11/14/2026 |
Updated Multiple NuGet packages