Notavia.Prefs.Blazor 1.0.3

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

Notavia.Prefs.Blazor

Razor component that mounts the <notifyservice-prefs> web component inside a Blazor-managed <div> and bridges its custom events to EventCallback<T> parameters via IJSObjectReference. Works in Blazor Server and Blazor WebAssembly.

Install

dotnet add package Notavia.Prefs.Blazor

Quickstart

@page "/account/notifications"
@using NotifyService.Prefs.Blazor

<NotifyServicePrefs
    PublishableKey="@_pk"
    Token="@_token"
    Layout="PrefsLayout.Auto"
    OnPrefsChanged="HandlePrefsChanged"
    OnError="HandleError" />

@code {
    string _pk = "npk_test_…";
    string _token = "";

    protected override async Task OnInitializedAsync()
        => _token = await GetTokenAsync();

    Task GetTokenAsync()
        => /* call your backend endpoint that mints the delegated JWT with scope "prefs" */;

    Task HandlePrefsChanged(PreferenceCell cell)
    {
        Console.WriteLine($"Pref changed: {cell.CategoryKey}/{cell.Channel} opted={cell.OptedIn}");
        return Task.CompletedTask;
    }

    Task HandleError(string message)
    {
        Console.WriteLine($"Prefs error: {message}");
        return Task.CompletedTask;
    }
}

Parameters

Parameter Type Required Default Description
PublishableKey string Yes — Tenant + environment identifier. Begins with npk_live_ or npk_test_.
Token string Yes — Delegated JWT minted by your backend. Must carry scope: "prefs" or scope: "inbox prefs".
BaseUrl string No "https://api.notavia.saas-infrastructure.com" Override for self-hosted or staging environments.
Layout PrefsLayout No PrefsLayout.Auto Visual presentation: Auto, Table, or Cards.
OnPrefsChanged EventCallback<PreferenceCell> No — Fires when the user toggles a preference.
OnError EventCallback<string> No — Fires when the embeddable surfaces an unrecoverable error.

JWT scope requirement

The delegated JWT minted by your backend must carry scope: "prefs". If the same token is reused for the inbox widget, use scope: "inbox prefs" (space-separated).

// Example using the NotifyService .NET SDK token minter
var token = _tokenMinter.Mint(new UnsubscribeTokenClaims(
    externalUserId: currentUser.Id,
    organizationId: organization.Id,
    scope: "prefs"
));

Pass the resulting JWT string as the Token parameter. Set up an API endpoint that returns a fresh token and wire it to refreshToken via the JS interop layer — or, for Blazor Server, simply call StateHasChanged() with an updated token when the underlying session refreshes.

How it works

On first render (OnAfterRenderAsync(firstRender: true)) the component imports a collocated JS module (notifyservice-prefs-blazor.js) via IJSObjectReference. That module imports the <notifyservice-prefs> custom element from the vendored UMD bundle, mounts it inside the Blazor-managed <div>, and wires custom events to [JSInvokable] methods on the component's DotNetObjectReference.

Target frameworks

net8.0 and net10.0. Compatible with Blazor Server and Blazor WebAssembly on both target frameworks.

License

MIT.

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

    • No dependencies.
  • net8.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
1.0.3 79 9/24/2026
1.0.2 289 8/15/2026
1.0.1 149 8/14/2026
1.0.0 108 8/14/2026