Soenneker.Blazor.Utils.IndexedDb
11.0.269
Prefix Reserved
dotnet add package Soenneker.Blazor.Utils.IndexedDb --version 11.0.269
NuGet\Install-Package Soenneker.Blazor.Utils.IndexedDb -Version 11.0.269
<PackageReference Include="Soenneker.Blazor.Utils.IndexedDb" Version="11.0.269" />
<PackageVersion Include="Soenneker.Blazor.Utils.IndexedDb" Version="11.0.269" />
<PackageReference Include="Soenneker.Blazor.Utils.IndexedDb" />
paket add Soenneker.Blazor.Utils.IndexedDb --version 11.0.269
#r "nuget: Soenneker.Blazor.Utils.IndexedDb, 11.0.269"
#:package Soenneker.Blazor.Utils.IndexedDb@11.0.269
#addin nuget:?package=Soenneker.Blazor.Utils.IndexedDb&version=11.0.269
#tool nuget:?package=Soenneker.Blazor.Utils.IndexedDb&version=11.0.269
Soenneker.Blazor.Utils.IndexedDb
A scoped Blazor utility for storing strings and JSON-serialized .NET values in browser IndexedDB object stores.
The API manages simple key/value stores with string keys. It does not expose indexes, cursors, compound keys, or multi-operation transactions.
Installation
dotnet add package Soenneker.Blazor.Utils.IndexedDb
using Soenneker.Blazor.Utils.IndexedDb.Registrars;
builder.Services.AddIndexedDbUtilAsScoped();
@using Soenneker.Blazor.Utils.IndexedDb.Abstract
@inject IIndexedDbUtil IndexedDb
IndexedDB is a browser API. Call the service after interactive rendering, not during server prerendering.
Store and retrieve a value
Set creates the database and object store when necessary:
const string database = "my-app";
const string store = "preferences";
await IndexedDb.Set(database, store, "theme", "dark");
string? theme = await IndexedDb.Get(database, store, "theme");
bool exists = await IndexedDb.ContainsKey(database, store, "theme");
Get returns null when the database, store, or key does not exist. A stored empty string is returned as an empty string. Database names, store names, and keys must be non-empty strings.
Initialize() is optional; it eagerly loads the JavaScript module but does not open a database. EnsureStore() is useful when an application wants to provision a store before its first write.
Store typed values
Non-string values are serialized to JSON before storage and deserialized on read:
public sealed record UserPreference(string Theme, bool SidebarCollapsed);
var preference = new UserPreference("dark", true);
await IndexedDb.Set(database, store, "user:42", preference);
UserPreference? loaded =
await IndexedDb.Get<UserPreference>(database, store, "user:42");
Values passed to either Set overload cannot be null. The store contains the JSON string, not a native IndexedDB structured-clone object. Incompatible JSON or a changed .NET model can cause deserialization to fail. Version stored models and handle migration in application code when their shape evolves.
Get<T> returns the default value both when a key is missing and when stored JSON represents null. Use ContainsKey when that distinction matters.
Inspect and modify a store
IReadOnlyList<UserPreference> preferences =
await IndexedDb.GetAll<UserPreference>(database, store);
IReadOnlyList<string> keys = await IndexedDb.GetKeys(database, store);
int count = await IndexedDb.GetLength(database, store);
await IndexedDb.Remove(database, store, "user:42");
await IndexedDb.Clear(database, store);
GetAll<T> returns values without their keys. For non-string types, blank values and values deserialized as null are omitted. Each method runs its own IndexedDB transaction, so a sequence of calls is not atomic and another tab can change data between them.
Database and schema behavior
await IndexedDb.EnsureStore(database, "outbox");
await IndexedDb.DeleteDatabase(database);
Adding a missing store upgrades the IndexedDB database version. Open connections created by this library close when another context requests a version change, but unrelated connections in another tab can block an upgrade or deletion until they close.
DeleteDatabase removes every store and value in the named database. Treat the name as a trusted application constant and require deliberate user intent before exposing that operation in a UI.
Cancellation stops waiting for the Blazor interop call; browsers do not provide a reliable way to abort every IndexedDB open, upgrade, or deletion request after it has started. Verify state before retrying a cancelled destructive operation.
Storage and security
IndexedDB is origin-scoped browser storage, not durable server storage. Browsers can evict it, users can clear it, private sessions can discard it, and writes can fail because of quota or policy. Handle exceptions and keep authoritative data elsewhere.
Data is not encrypted by this library and is readable by JavaScript running on the same origin. Do not store passwords, bearer tokens, private keys, or other high-value secrets. Treat retrieved values as untrusted input and validate them before use.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Blazor.Utils.ModuleImport (>= 11.0.1959)
- Soenneker.Utils.Json (>= 11.0.2825)
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.269 | 48 | 12/3/2026 |
| 11.0.268 | 49 | 12/3/2026 |
| 11.0.267 | 58 | 12/3/2026 |
| 11.0.266 | 60 | 12/3/2026 |
| 11.0.265 | 52 | 12/3/2026 |
| 11.0.264 | 55 | 12/3/2026 |
| 11.0.263 | 52 | 12/3/2026 |
| 11.0.262 | 53 | 12/2/2026 |
| 11.0.261 | 53 | 12/2/2026 |
| 11.0.258 | 44 | 12/2/2026 |
| 11.0.257 | 51 | 12/2/2026 |
| 11.0.256 | 53 | 12/2/2026 |
| 11.0.255 | 55 | 12/2/2026 |
| 11.0.254 | 58 | 12/2/2026 |
| 11.0.253 | 54 | 12/2/2026 |
| 11.0.252 | 56 | 12/1/2026 |
| 11.0.251 | 57 | 12/1/2026 |
| 11.0.250 | 54 | 12/1/2026 |
| 11.0.249 | 59 | 12/1/2026 |
| 11.0.248 | 53 | 12/1/2026 |
Updated Multiple NuGet packages