Ecs.Libs.Blazor.Storage 0.2.6

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

Using the Ecs.Libs.Blazor.Storage Library

The Ecs.Libs.Blazor.Storage library provides a simple and efficient way to manage local and session storage in Blazor applications. This guide will help you get started with using the library in your Blazor projects.

Installation

To install the Ecs.Libs.Blazor.Storage library, you can use the NuGet Package Manager Console or the .NET CLI. Using the NuGet Package Manager Console:

Install-Package Ecs.Libs.Blazor.Storage

Using the .NET CLI:

dotnet add package Ecs.Libs.Blazor.Storage

Configuration

After installing the package, you need to configure the storage services in your Blazor application. Open the Program.cs file and add the following lines to register the storage services:

using Ecs.Libs.Blazor.Storage;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddStorageServices();

There is also an option to configure the storage services with custom settings:

builder.Services.AddStorageServices(options =>
{
	// Customize storage key settings if needed
	options.UseApplicationKeyPrefix = true;
	options.ApplicationKeyPrefix = "custom-app-identifier-prefix";
	options.PrefixSeparator = '-';
	options.AlwaysStoreAsJson = false;
});

Usage

Once the services are registered, you can inject the storage service into your Blazor components or services. Here�s an example of how to use local storage:

@inject IStorageService storageService
@code {
	private async Task SaveDataAsync()
	{
		await storageService.Local.SetItemAsync("key", "value");
	}
	private async Task<string> GetDataAsync()
	{
		return await storageService.Local.GetItemAsync<string>("key", "default value");
	}
	private async Task RemoveDataAsync()
	{
		await storageService.Local.RemoveItemAsync("key");
	}
	private async Task ClearAsync()
	{
		await storageService.Local.ClearAsync();
	}
	private async Task<IEnumerable<string>> GetAllKeysAsync()
	{
		return await storageService.Local.KeysAsync();
	}
}

Session Storage

You can also use session storage:

@inject IStorageService storageService
@code {
	private async Task SaveSessionDataAsync()
	{
		await storageService.Session.SetItemAsync("sessionKey", "sessionValue");
	}
	private async Task<string> GetSessionDataAsync()
	{
		return await storageService.Session.GetItemAsync<string>("sessionKey", "default session value");
	}
	private async Task RemoveSessionDataAsync()
	{
		await storageService.Session.RemoveItemAsync("sessionKey");
	}
	private async Task ClearSessionStorageAsync()
	{
		await storageService.Session.ClearAsync();
	}
	private async Task<IEnumerable<string>> GetAllKeysAsync()
	{
		return await storageService.Session.KeysAsync();
	}
}

Manage Storage Items with ApplicationStorage component

The ApplicationStorage component allows you to manage storage items declaratively in your Blazor components. Here�s an example of how to use it:

@page "/storage"
@using Ecs.Libs.Blazor.Storage

<ApplicationStorage ShowInterface="true" />

@code {

}

Added abilitiy to control debug logging for storage operations


@using Ecs.Libs.Blazor.Storage

<ApplicationStorage EnableDebugLogging="Debug" />

@code {

 [Parameter]
 public bool Debug { get; set; } = false;

}
Screensot of component in action

ApplicationStorage Component Screenshot

Screenshot of component in action if services were not properly registered

ApplicationStorage Component Not Registered Screenshot

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.

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
0.2.6 93 1/2/2026
0.2.5 84 1/1/2026
0.2.4 80 1/1/2026
0.2.3 85 1/1/2026
0.2.2 86 12/26/2025
0.2.1 90 12/26/2025
0.2.0 95 12/26/2025
0.1.0 140 12/26/2025
0.1.0-rc 142 12/26/2025