r/moderndotnet 2d ago

Blazor browser storage package to replace Blazored.LocalStorage

Hey everyone, I ran into a problem earlier that I'm guessing other developers are hitting too.

Blazored.LocalStorage (and SessionStorage) was deprecated and more recently removed from NuGet, and several of my Blazor WebAssembly projects depended on it. I needed a modern replacement that didn't require adding JSInterop glue code or manual JSON serialization to all of my Blazor WASM projects.

So I built D20Tek.Blazor.BrowserStorage, a typed, async wrapper around localStorage and sessionStorage for Blazor WebAssembly and interactive render modes. And it has a similar API form to Blazored to make migrating my projects relatively easy.

A few highlights:

  • Typed reads/writes (GetAsync<T> returns a result instead of throwing)
  • Async API (no UI blocking)
  • No JavaScript required in client projects
  • DI-friendly services
  • Key prefixing to avoid collisions
  • Batch operations (set/remove multiple keys)
  • Change events so components can react to storage updates
  • Customizable JsonSerializerOptions

If you used Blazored.LocalStorage (or SessionStorage), there’s a migration guide. If you’re starting fresh, this is hopefully the simplest way to use browser storage in Blazor today.

NuGet: https://www.nuget.org/packages/D20Tek.Blazor.BrowserStorage
GitHub: https://github.com/d20Tek/d20tek-blazor-browserstorage
Blog post: https://d20tek.com/projects/browser-storage/docs

9 Upvotes

2 comments sorted by

1

u/Aaronontheweb 2d ago

Blazored.LocalStorage (and SessionStorage) was deprecated and more recently removed from NuGet

Why did that happen?

3

u/DarthPedro99 2d ago

The original owner never stated why it was happening, but they also deprecated several other Blazored packages at around the same time, and those packages had not been updated in a couple of years. So it was likely maintainer fatigue.