https://github.com/soenneker/soenneker.blazor.utils.indexeddb
A Blazor utility library for managing IndexedDB
https://github.com/soenneker/soenneker.blazor.utils.indexeddb
blazor blazorlibrary csharp dotnet indexeddb indexeddbutil js storage utils
Last synced: 29 days ago
JSON representation
A Blazor utility library for managing IndexedDB
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.blazor.utils.indexeddb
- Owner: soenneker
- License: mit
- Created: 2026-03-25T20:46:09.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-05-26T23:02:40.000Z (about 1 month ago)
- Last Synced: 2026-05-27T01:09:06.238Z (about 1 month ago)
- Topics: blazor, blazorlibrary, csharp, dotnet, indexeddb, indexeddbutil, js, storage, utils
- Language: CSS
- Homepage: https://soenneker.com
- Size: 384 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.blazor.utils.indexeddb/)
[](https://github.com/soenneker/soenneker.blazor.utils.indexeddb/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.blazor.utils.indexeddb/)
[](https://soenneker.github.io/soenneker.blazor.utils.indexeddb)
[](https://github.com/soenneker/soenneker.blazor.utils.indexeddb/actions/workflows/codeql.yml)
#  Soenneker.Blazor.Utils.IndexedDb
### A Blazor utility library for managing IndexedDB
## Installation
```bash
dotnet add package Soenneker.Blazor.Utils.IndexedDb
```
## Setup
Register services in `Program.cs`:
```csharp
builder.Services.AddIndexedDbUtilAsScoped();
```
Inject the higher-level utility where you need it:
```csharp
@inject IIndexedDbUtil IndexedDb
```
## Usage
Initialize the package once before first use, ensure the store exists, then read/write values by `databaseName`, `storeName`, and `key`:
```csharp
await IndexedDb.Initialize();
const string databaseName = "app";
const string storeName = "settings";
const string key = "theme";
await IndexedDb.EnsureStore(databaseName, storeName);
await IndexedDb.Set(databaseName, storeName, key, "dark");
string? theme = await IndexedDb.Get(databaseName, storeName, key);
bool hasTheme = await IndexedDb.ContainsKey(databaseName, storeName, key);
int count = await IndexedDb.GetLength(databaseName, storeName);
```
You can also store typed objects; values are JSON-serialized by `IIndexedDbUtil`:
```csharp
public sealed record UserPreference(string Theme, bool SidebarCollapsed);
await IndexedDb.Set("app", "preferences", "user:1", new UserPreference("dark", true));
UserPreference? preference = await IndexedDb.Get("app", "preferences", "user:1");
```