Skip to content
Document DB v7: Temporal Support Feed The Machine Here

Blazor Hosting

Shiny Blazor Hosting provides an IAppSupport service for Blazor WebAssembly apps — app version, browser user-agent, screen and viewport dimensions, plus live culture and time-zone change notifications. It’s the browser-side sibling of MAUI Hosting’s IAppSupport, reading browser state synchronously through IJSInProcessRuntime (the same approach as Stores for WebAssembly).

GitHubGitHub stars for shinyorg/extensions
DownloadsNuGet downloads for Shiny.Extensions.BlazorHosting
Frameworks
Blazor
Operating Systems
Web
  • IAppSupport — app version, browser user-agent (raw string + best-effort parsed browser Version), screen and viewport dimensions
  • Live CultureChanged / TimeZoneChanged events with lazy subscription
  • Synchronous browser reads via IJSInProcessRuntime — no await needed for property access
  • App version supplied at registration from the head assembly’s ThisAssembly constant — no runtime reflection
  1. Install the NuGet package:

    Terminal window
    dotnet add package Shiny.Extensions.BlazorHosting
  2. Reference the bundled script in wwwroot/index.html, before blazor.webassembly.js:

    <script src="_content/Shiny.Extensions.BlazorHosting/shiny-appsupport.js"></script>
  3. Register in Program.cs, passing your app’s version constant:

    using Shiny;
    var builder = WebAssemblyHostBuilder.CreateDefault(args);
    builder.Services.AddAppSupport(ThisAssembly.AssemblyVersion);
    await builder.Build().RunAsync();
@inject IAppSupport App
@code {
protected override void OnInitialized()
{
// Snapshot
Version version = App.AppVersion;
string? userAgent = App.UserAgent;
Version? browser = App.UserAgentVersion; // best-effort, may be null
var (w, h) = (App.BrowserWidth, App.BrowserHeight); // viewport — read live
var (sw, sh) = (App.ScreenWidth, App.ScreenHeight); // physical screen
// Live updates
App.CultureChanged += (s, e) => InvokeAsync(StateHasChanged);
App.TimeZoneChanged += (s, e) => InvokeAsync(StateHasChanged);
}
}
MemberSourceNotes
AppVersionRegistration argumentPass ThisAssembly.AssemblyVersion (or another compile-time constant) — never reflected
UserAgentnavigator.userAgentRead once and cached for the page’s lifetime
UserAgentVersionParsed from UserAgentBest-effort browser version (Edge → Opera → Firefox → Chrome → Safari); null if unparseable
ScreenWidth, ScreenHeightwindow.screen.*Physical screen size
BrowserWidth, BrowserHeightwindow.innerWidth/innerHeightViewport — read live, so reflects window resizes
CurrentCulture + CultureChangedCultureInfo.CurrentCulture30-second poller raises the event on change
CurrentTimeZone + TimeZoneChangedTimeZoneInfo.Local30-second poller raises the event on change
claude plugin marketplace add shinyorg/skills
claude plugin install shiny-extensions@shiny
copilot plugin marketplace add https://github.com/shinyorg/skills
copilot plugin install shiny-extensions@shiny
View shiny-extensions Plugin