![]() |
VOOZH | about |
dotnet add package Tavenem.Blazor.IndexedDB --version 7.1.2
NuGet\Install-Package Tavenem.Blazor.IndexedDB -Version 7.1.2
<PackageReference Include="Tavenem.Blazor.IndexedDB" Version="7.1.2" />
<PackageVersion Include="Tavenem.Blazor.IndexedDB" Version="7.1.2" />Directory.Packages.props
<PackageReference Include="Tavenem.Blazor.IndexedDB" />Project file
paket add Tavenem.Blazor.IndexedDB --version 7.1.2
#r "nuget: Tavenem.Blazor.IndexedDB, 7.1.2"
#:package Tavenem.Blazor.IndexedDB@7.1.2
#addin nuget:?package=Tavenem.Blazor.IndexedDB&version=7.1.2Install as a Cake Addin
#tool nuget:?package=Tavenem.Blazor.IndexedDB&version=7.1.2Install as a Cake Tool
Tavenem.Blazor.IndexedDB is a Razor class library (RCL) containing a Razor component. It grants managed access to the IndexedDB API.
It uses the idb javascript library by Jake Archibald, and implements the IDataStore interface from the Tavenem DataStore library.
Tavenem.Blazor.IndexedDB is available as a NuGet package.
Register the IndexedDbService with dependency injection.
builder.Services.AddIndexedDbService();
Register one or more IndexedDb instances with dependency injection.
// simple
builder.Services.AddIndexedDb("myDatabaseName");
// all options
builder.Services.AddIndexedDb(
databaseName: "myDatabaseName", // the database name
objectStores: ["valueStore"], // the names of value stores
version: 2, // the version number of the current database schema
jsonSerializerOptions: new(JsonSerializerDefaults.Web), // a JsonSerializerOptions instance
key: "id"); // the name of the property to use as the primary key in stored objects
Note that use of dependency injection for database instances is optional. They can also be
initialized on demand with their public constructor, which requires an instance of
IndexedDbService.
Inject an IndexedDb instance in a component.
[Inject(Key = "myDatabaseName")] private IndexedDb MyDatabase { get; set; } = default!;
Note that the @inject directive does not currently support keyed services.
Retrieve an IndexedDbStore instance by name.
var store = MyDatabase["valueStore"];
Call the StoreItemAsync<T>, GetItemAsync<T>, and RemoveItemAsync<T> methods on an IndexedDbStore to work with strongly-typed data items.
class Item : IIdItem
{
public string Id { get; set; }
public string? Value { get; set; }
}
var item = new Item
{
Id = "1",
Value = "Hello, World!",
};
await store.StoreItemAsync(item);
item.Value = "Goodbye!";
await store.StoreItemAsync(item);
var fetchedItem = await store.GetItemAsync<Item>(item.Id);
// fetchedItem is an Item instance: item.Value == "Goodbye!"
await store.RemoveItemAsync(item);
fetchedItem = await store.GetItemAsync<Item>(item.Id);
// fetchedItem is null
Call the Query<T> method to obtain an IDataStoreQueryable<T>. IDataStoreQueryable<T> is similar to IQueryable<T>, and can be used to make queries against the data source.
await foreach (var item in store.Query<Item>().AsAsyncEnumerable())
{
Console.WriteLine(item.Value);
}
var helloCount = await store
.Query<Item>()
.Select(x => x.Value != null && x.Value.Contains("Hello"))
.CountAsync();
Call the ClearAsync, CountAsync, and GetAllAsync<T> methods to work with the full object store.
await store.StoreItemAsync(item);
var count = await store.CountAsync();
// count = 1
var items = await store.GetAllAsync<Item>();
// items is an array of Items with Length 1
await store.ClearAsync();
count = await store.CountAsync();
// count = 0
Call the DeleteDatabaseAsync method on the IndexedDb instance to remove the entire database.
await MyDatabase.DeleteDatabaseAsync();
// the database has been removed (or will be, after all connections are closed)
New versions of Tavenem.IndexedDb should be expected whenever the API surface of the Tavenem DataStore library receives an update.
There is a preview release available now. See README_preview.md for an updated example of how to use the new API.
Other updates to resolve bugs or add new features may occur at any time.
Contributions are always welcome. Please carefully read the document to learn more before submitting issues or pull requests.
Please read the before engaging with our community, including but not limited to submitting or replying to an issue or pull request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Tavenem.Blazor.IndexedDB:
| Package | Downloads |
|---|---|
|
H.Necessaire.Runtime.UI.Razor
A Core Framework for Rapid Application Development |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.1.2 | 440 | 4/21/2026 |
| 7.0.7 | 68 | 4/21/2026 |
| 6.4.1 | 8,987 | 9/17/2025 |
| 6.3.4 | 1,428 | 7/31/2025 |
| 6.2.5 | 250 | 7/30/2025 |
| 6.1.5 | 694 | 7/23/2025 |
| 6.0.6 | 548 | 6/24/2025 |
| 5.1.4 | 1,281 | 1/24/2025 |
| 5.0.2 | 556 | 12/27/2024 |
| 4.2.4 | 324 | 12/17/2024 |
| 4.1.4 | 422 | 11/21/2024 |
| 4.0.2 | 1,596 | 6/30/2024 |
| 3.0.2 | 970 | 3/20/2024 |
| 2.3.4 | 341 | 3/5/2024 |
| 2.2.4 | 308 | 2/12/2024 |
| 2.1.2 | 338 | 11/29/2023 |
| 2.0.1 | 255 | 11/27/2023 |