HTML5 Storage API for Blazor without any JavaScript Library Dependency.
This package wraps HTML5 Storage APIs.
Both Session and Local storage types are supported.
Install-Package BlazorBrowserStorage -Version 1.0.0
services.AddBlazorBrowserStorage();
This library was ported and improved from BlazorExtensions.Storage but removing any javascript dependency.
[Inject] ISessionStorage SessionStorage { get; set; }
for session storage
[Inject] ILocalStorage LocalStorage { get; set; }
for local storage
BlazorBrowserStorage ISessionStorage/ILocalStorage | Method |
---|---|
Gets the Length of items in storage | Length() |
Clears all items in storage | Clear() |
Gets an item by key of a type from the storage | GetItem<T>(string key) |
Gets a key name by index from the storage | Key() |
Remove an item by key from the storage | RemoveItem(string key) |
Sets an item by key and by item type in the storage | SetItem<T>(string key, T item) |
MIT