Soenneker.Blazor.Utils.JsVariable 4.0.1361

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Blazor.Utils.JsVariable --version 4.0.1361
                    
NuGet\Install-Package Soenneker.Blazor.Utils.JsVariable -Version 4.0.1361
                    
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="Soenneker.Blazor.Utils.JsVariable" Version="4.0.1361" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.Utils.JsVariable" Version="4.0.1361" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Utils.JsVariable" />
                    
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 Soenneker.Blazor.Utils.JsVariable --version 4.0.1361
                    
#r "nuget: Soenneker.Blazor.Utils.JsVariable, 4.0.1361"
                    
#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 Soenneker.Blazor.Utils.JsVariable@4.0.1361
                    
#: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=Soenneker.Blazor.Utils.JsVariable&version=4.0.1361
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Utils.JsVariable&version=4.0.1361
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Blazor.Utils.JsVariable

A scoped Blazor interop service for checking whether a globalThis property exists and waiting for a script-created global to become available.

Use it when integrating a third-party script that exposes readiness only by assigning a global object. Prefer the script’s documented load event or initialization promise when one exists.

Installation

dotnet add package Soenneker.Blazor.Utils.JsVariable
using Soenneker.Blazor.Utils.JsVariable.Registrars;

builder.Services.AddJsVariableInteropAsScoped();
@using Soenneker.Blazor.Utils.JsVariable.Abstract
@inject IJsVariableInterop JsVariables

The checks require browser interop, so call them after interactive rendering rather than during server prerendering.

Check once

bool mapsReady = await JsVariables.IsVariableAvailable("google.maps");

Paths are dot-separated and resolved from globalThis. Every segment must be an own data property. Prototype traversal and accessor execution are deliberately excluded, so inherited properties and getter-only globals are reported as unavailable.

A property whose value is null counts as available. A missing property or one whose value is JavaScript undefined does not.

Wait with a timeout

try
{
    await JsVariables.WaitForVariable(
        "google.maps",
        delay: 25,
        timeout: 5_000,
        cancellationToken);

    // The global existed at the end of the wait. Use the owning SDK here.
}
catch (TimeoutException)
{
    // The script did not expose the global within five seconds.
}

delay and timeout are milliseconds. Delay must be greater than zero; timeout can be zero for an immediate check. With no timeout, the wait continues until the value appears, cancellation is requested, or the scoped service is disposed.

Each wait has independent timer state. Cancellation clears its browser timer, settles the pending JavaScript promise, and propagates OperationCanceledException. A timeout is surfaced as TimeoutException.

Availability is only a point-in-time observation. Another script can replace or remove the property immediately afterward, so the subsequent SDK call must still handle its own errors.

Path and trust guidance

Use paths defined by the application or SDK documentation. Empty path segments and __proto__, prototype, or constructor segments are rejected.

Do not use global-variable availability as proof that a script is trustworthy, that a user is authorized, or that an SDK response is safe. Any script running in the page can create or replace globals, and values received from JavaScript still require validation.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Soenneker.Blazor.Utils.JsVariable:

Package Downloads
Soenneker.Blazor.Utils.ResourceLoader

A Blazor JavaScript interop for dynamically loading scripts, styles, and modules

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1363 0 8/30/2026
4.0.1362 0 8/30/2026
4.0.1361 0 8/30/2026
4.0.1359 21 8/29/2026
4.0.1358 27 8/29/2026
4.0.1357 38 8/29/2026
4.0.1356 1,209 8/26/2026
4.0.1355 421 8/26/2026
4.0.1354 2,543 8/21/2026
4.0.1353 2,653 8/18/2026
4.0.1352 1,864 8/13/2026
4.0.1351 720 8/12/2026
4.0.1350 3,142 8/9/2026
4.0.1349 1,616 8/8/2026
4.0.1348 583 8/8/2026
4.0.1347 2,925 8/7/2026
4.0.1346 2,494 7/29/2026
4.0.1345 2,148 7/29/2026
4.0.1344 337 7/28/2026
4.0.1343 402 7/28/2026
Loading failed

Update dependency Soenneker.Blazor.Utils.Ids to 4.0.22 (#1916)