{"id":13466544,"url":"https://github.com/BlazorExtensions/Storage","last_synced_at":"2025-03-25T21:32:27.910Z","repository":{"id":42461706,"uuid":"133167424","full_name":"BlazorExtensions/Storage","owner":"BlazorExtensions","description":"HTML5 Storage API implementation for Microsoft Blazor","archived":false,"fork":false,"pushed_at":"2023-01-13T22:17:28.000Z","size":575,"stargazers_count":229,"open_issues_count":23,"forks_count":35,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-20T10:45:28.223Z","etag":null,"topics":["blazor","html5-storage","storage","web-assembly","webassembly"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlazorExtensions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-12T17:16:05.000Z","updated_at":"2025-02-23T00:07:11.000Z","dependencies_parsed_at":"2023-02-09T17:15:47.719Z","dependency_job_id":null,"html_url":"https://github.com/BlazorExtensions/Storage","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlazorExtensions%2FStorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlazorExtensions%2FStorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlazorExtensions%2FStorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlazorExtensions%2FStorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlazorExtensions","download_url":"https://codeload.github.com/BlazorExtensions/Storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245548522,"owners_count":20633602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","html5-storage","storage","web-assembly","webassembly"],"created_at":"2024-07-31T15:00:45.921Z","updated_at":"2025-03-25T21:32:27.617Z","avatar_url":"https://github.com/BlazorExtensions.png","language":"C#","readme":"[![Build](https://github.com/BlazorExtensions/Storage/workflows/CI/badge.svg)](https://github.com/BlazorExtensions/Storage/actions)\r\n[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.Storage.svg)](https://www.nuget.org/packages/Blazor.Extensions.Storage)\r\n[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.Storage.svg)](https://www.nuget.org/packages/Blazor.Extensions.Storage)\r\n[![License](https://img.shields.io/github/license/BlazorExtensions/Storage.svg)](https://github.com/BlazorExtensions/Storage/blob/master/LICENSE)\r\n\r\n# Blazor Extensions\r\n\r\nBlazor Extensions are a set of packages with the goal of adding useful things to [Blazor](https://blazor.net).\r\n\r\n# Blazor Extensions Storage\r\n\r\nThis package wraps [HTML5 Storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) APIs. Both Session and Local storage types are supported.\r\n\r\n# Sample configuration\r\n\r\n## Setup\r\n\r\nThe following snippet shows how to setup the storage wrapper by registering it for dependency injection in the ```Startup.cs``` of the application.\r\n\r\n```c#\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n    // Add Blazor.Extensions.Storage\r\n    // Both ISessionStorage and ILocalStorage are registered\r\n    services.AddStorage();\r\n}\r\n```\r\n\r\n## Usage\r\n\r\nThe following snippet shows how to consume the storage API in a Blazor component.\r\n\r\n```c#\r\n@inject ISessionStorage sessionStorage\r\n@inject ILocalStorage localStorage\r\n\r\n@functions {\r\n  protected override async Task OnInitAsync()\r\n  {\r\n        var key = \"forecasts\";\r\n        await sessionStorage.SetItem\u003cWeatherForecast[]\u003e(key, forecasts);\r\n        await localStorage.SetItem\u003cWeatherForecast[]\u003e(key, forecasts);\r\n        var fromSession = await sessionStorage.GetItem\u003cWeatherForecast[]\u003e(key);\r\n        var fromLocal = await localStorage.GetItem\u003cWeatherForecast[]\u003e(key);\r\n  }\r\n}\r\n```\r\n\r\nIf you want to consume it outside of a ```cshtml``` based component, then you can use the ```Inject``` attribute to inject it into the class.\r\n\r\n```c#\r\n[Inject]\r\nprotected ISessionStorage sessionStorage;\r\n\r\n[Inject]\r\nprotected ILocalStorage localStorage;\r\n\r\npublic Task LogSomething()\r\n{\r\n        var key = \"forecasts\";\r\n        await sessionStorage.SetItem\u003cWeatherForecast[]\u003e(key, forecasts);\r\n        await localStorage.SetItem\u003cWeatherForecast[]\u003e(key, forecasts);\r\n        var fromSession = await sessionStorage.GetItem\u003cWeatherForecast[]\u003e(key);\r\n        var fromLocal = await localStorage.GetItem\u003cWeatherForecast[]\u003e(key);\r\n}\r\n```\r\n\r\n# Contributions and feedback\r\n\r\nPlease feel free to use the component, open issues, fix bugs or provide feedback.\r\n\r\n# Contributors\r\n\r\nThe following people are the maintainers of the Blazor Extensions projects:\r\n\r\n- [Attila Hajdrik](https://github.com/attilah)\r\n- [Gutemberg Ribiero](https://github.com/galvesribeiro)\r\n","funding_links":[],"categories":["Libraries \u0026 Extensions"],"sub_categories":["Tools \u0026 Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBlazorExtensions%2FStorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBlazorExtensions%2FStorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBlazorExtensions%2FStorage/lists"}