StateStorage 1.0.8
dotnet add package StateStorage --version 1.0.8
NuGet\Install-Package StateStorage -Version 1.0.8
<PackageReference Include="StateStorage" Version="1.0.8" />
<PackageVersion Include="StateStorage" Version="1.0.8" />
<PackageReference Include="StateStorage" />
paket add StateStorage --version 1.0.8
#r "nuget: StateStorage, 1.0.8"
#:package StateStorage@1.0.8
#addin nuget:?package=StateStorage&version=1.0.8
#tool nuget:?package=StateStorage&version=1.0.8
<p align="center"> <img src="logo.png" alt="StateStorage Logo" width="96" height="96"/> </p>
<h1 align="center">StateStorage</h1>
<p align="center"> Unified, automatic, and intelligent state storage for Blazor (WASM, Server, SSR, Auto). </p>
<p align="center"> <a href="https://www.nuget.org/packages/StateStorage"> <img src="https://img.shields.io/nuget/v/StateStorage.svg?label=NuGet&color=0078D4" /> </a> <a href="https://www.nuget.org/packages/StateStorage"> <img src="https://img.shields.io/nuget/dt/StateStorage.svg?color=gray" /> </a> </p>
🚀 Overview
StateStorage is a unified, automatic, multi‑backend state management library for Blazor.
It provides a single API that works seamlessly across WASM, Server, SSR, and Auto render modes.
✨ Features
- 🔄 Unified API — one interface for all Blazor modes
- 🤖 Automatic backend selection (WASM, Cookies, Memory, Server)
- 🧩 Plug‑and‑play — no configuration required
- 🧪 Typed storage with JSON serialization
- ⚡ Zero dependencies, lightweight, production‑ready
- 🌐 Compatible with .NET 8, 9, 10
🚀 Installation
dotnet add package StateStorage
🛠 Setup
Server / Auto
builder.Services.AddStateStorage()
.UseAuto(); // Automatically selects the best backend
WASM
builder.Services.AddStateStorage()
.UseWasm()
.UseFallback(StateStorageBackend.Wasm);
📦 Usage
Save
@inject IStateStorage State
<button @onclick="Save">Save</button>
@code {
private async Task Save()
{
await State.SetAsync("key", "value");
}
}
Load
var value = await State.GetAsync<string>("key");
Remove
await State.RemoveAsync("key");
Exists
bool exists = await State.ExistsAsync("key");
🧠 Backends
| Mode | Backend | Description |
|---|---|---|
| WASM | LocalStorage | Fast, persistent |
| Server | Cookies | Works with prerender |
| SSR | Memory | Ephemeral |
| Auto | Smart choice | Automatically selects |
This repository includes three full demo pages, one for each Blazor render mode:
🔹 WASM Demo
/profile page
Save / Load / Remove / Exists
Uses LocalStorage
Runs fully client‑side
👉 Direct link:
https://github.com/alain-mathy/StateStorageDemo_Wasm
🔹 Server Demo
/profile page
Save / Load / Remove / Exists
Uses Cookies / Server backend
Fully interactive server‑side
👉 Direct link:
https://github.com/alain-mathy/StateStorageDemo_Server
🔹 Auto Demo
The Auto demo is a single Auto project, but it contains two different demo pages:
Server-side Auto page
Rendered on the server, using the Server backend
(/profile inside the Auto project)
Client-side Auto page
Rendered on the client, using LocalStorage
(/profile-client inside the Auto project)
👉 Direct link to the Auto demo project:
https://github.com/alain-mathy/StateStorageDemo_Auto
Both pages are available inside this project and demonstrate how Auto mode switches backend automatically depending on where the component is rendered.
📄 License
MIT License. 🤝 Contributing
PRs are welcome. See CONTRIBUTING.md for guidelines.
| Product | Versions 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 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. |
-
net10.0
- Microsoft.AspNetCore.Components (>= 8.0.0)
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.JSInterop (>= 8.0.0)
-
net8.0
- Microsoft.AspNetCore.Components (>= 8.0.0)
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.JSInterop (>= 8.0.0)
-
net9.0
- Microsoft.AspNetCore.Components (>= 8.0.0)
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.JSInterop (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.