StateStorage 1.0.8

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

<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.

Build NuGet Downloads License


✨ 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 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. 
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
1.0.8 53 5/2/2026
1.0.7 48 5/1/2026
1.0.6 47 5/1/2026
1.0.4 48 5/1/2026
1.0.3 46 5/1/2026
1.0.2 49 5/1/2026
1.0.1 53 5/1/2026
1.0.0 44 5/1/2026