Soenneker.Blazor.Utils.SessionStorage 11.0.199

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

Soenneker.Blazor.Utils.SessionStorage

Reads and writes browser sessionStorage from Blazor, with string and JSON-serialized typed APIs.

Install

dotnet add package Soenneker.Blazor.Utils.SessionStorage

Register the scoped services in Program.cs:

using Soenneker.Blazor.Utils.SessionStorage.Registrars;

builder.Services.AddSessionStorageUtilAsScoped();

Inject the higher-level utility into a component or service:

@using Soenneker.Blazor.Utils.SessionStorage.Abstract
@inject ISessionStorageUtil SessionStorage

Strings

await SessionStorage.Set("checkout.step", "shipping", cancellationToken);

string? step = await SessionStorage.Get("checkout.step", cancellationToken);

Get returns null when the key does not exist. Keys must contain at least one non-whitespace character, and string values cannot be null.

Typed values

The generic overloads serialize values with System.Text.Json web defaults:

public sealed record CheckoutDraft(string Email, int ItemCount);

var draft = new CheckoutDraft("buyer@example.com", 3);
await SessionStorage.Set("checkout.draft", draft, cancellationToken);

CheckoutDraft? restored =
    await SessionStorage.Get<CheckoutDraft>("checkout.draft", cancellationToken);

A missing key, stored JSON null, or an empty/whitespace stored value returns default(T). Malformed JSON or a value incompatible with T throws JsonException. Generic string calls use the raw string representation rather than JSON quoting.

Inspect and remove entries

bool exists = await SessionStorage.ContainsKey("checkout.draft", cancellationToken);
int count = await SessionStorage.GetLength(cancellationToken);
IReadOnlyList<string> keys = await SessionStorage.GetKeys(cancellationToken);

await SessionStorage.Remove("checkout.draft", cancellationToken);

GetKeys follows the browser's storage index order; do not treat it as sorted.

Clear removes every sessionStorage entry for the current origin, including entries created by other code:

await SessionStorage.Clear(cancellationToken);

Initialize is optional. Normal operations import the JavaScript module on demand; call it during component initialization only when you want to pay that cost ahead of the first storage operation.

Browser behavior and security

  • sessionStorage is scoped to the current origin and top-level browser tab. It survives reloads but is cleared when the tab's page session ends.
  • Browser privacy settings, storage policy, or quota limits can make an operation fail; the browser exception is propagated to the caller.
  • Storage is unavailable during server prerendering. Invoke this utility only after the component can perform JavaScript interop.
  • Values are not encrypted. Any script running on the origin can read them, so do not store access tokens, passwords, or other secrets here.
  • Cancellation stops the .NET wait but cannot undo a browser storage mutation that already completed.

Storage implementation

ISessionStorageUtil provides string and typed storage operations directly through Librarian. The utility and module importer are scoped and disposed by dependency injection; Librarian supplies the browser JavaScript.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.213 0 11/22/2026
11.0.212 53 11/20/2026
11.0.211 47 11/20/2026
11.0.210 46 11/20/2026
11.0.209 80 11/19/2026
11.0.208 49 11/19/2026
11.0.207 59 11/19/2026
11.0.206 49 11/19/2026
11.0.205 48 11/18/2026
11.0.204 48 11/18/2026
11.0.203 49 11/18/2026
11.0.202 53 11/18/2026
11.0.201 56 11/17/2026
11.0.200 47 11/17/2026
11.0.199 48 11/17/2026
11.0.198 90 11/16/2026
11.0.197 79 11/16/2026
11.0.196 93 11/16/2026
11.0.195 91 11/15/2026
11.0.194 94 11/15/2026
Loading failed

Updated Multiple NuGet packages