{"id":28387499,"url":"https://github.com/sachiharshitha/avaloniaui.browser.storage","last_synced_at":"2026-05-07T06:34:54.773Z","repository":{"id":296250290,"uuid":"992722660","full_name":"SachiHarshitha/AvaloniaUI.Browser.Storage","owner":"SachiHarshitha","description":"This project implements a simple storage adapter which the avalonia WASM apps can use to interact with the Browser storage.","archived":false,"fork":false,"pushed_at":"2025-06-02T18:14:06.000Z","size":447,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-06T18:20:52.508Z","etag":null,"topics":["avalonia","avaloniaui","browser","chrome","crossplatform","storage","storage-api","wasm"],"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/SachiHarshitha.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-29T15:56:51.000Z","updated_at":"2025-06-03T12:27:07.000Z","dependencies_parsed_at":"2025-05-29T18:44:52.361Z","dependency_job_id":"8b81962b-04a0-4d5a-b705-44c51b82ebf7","html_url":"https://github.com/SachiHarshitha/AvaloniaUI.Browser.Storage","commit_stats":null,"previous_names":["sachiharshitha/avaloniaui.browser.storage"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SachiHarshitha/AvaloniaUI.Browser.Storage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachiHarshitha%2FAvaloniaUI.Browser.Storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachiHarshitha%2FAvaloniaUI.Browser.Storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachiHarshitha%2FAvaloniaUI.Browser.Storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachiHarshitha%2FAvaloniaUI.Browser.Storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SachiHarshitha","download_url":"https://codeload.github.com/SachiHarshitha/AvaloniaUI.Browser.Storage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachiHarshitha%2FAvaloniaUI.Browser.Storage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262139690,"owners_count":23265209,"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":["avalonia","avaloniaui","browser","chrome","crossplatform","storage","storage-api","wasm"],"created_at":"2025-05-30T18:07:20.397Z","updated_at":"2026-05-07T06:34:54.740Z","avatar_url":"https://github.com/SachiHarshitha.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AvaloniaWASM.Storage\n\n[![NuGet](https://img.shields.io/nuget/v/AvaloniaWASM.Storage.svg)](https://www.nuget.org/packages/AvaloniaWASM.Storage/)\n[![Github All Releases](https://img.shields.io/nuget/dt/AvaloniaWASM.Storage.svg)]()\n\nThis library provides a simple way to use browser storage in AvaloniaUI applications. It supports both local, session storage as well as IndexedDB, allowing you to store key-value pairs that persist across sessions or only for the duration of the page load.\nThe IndexedDB support is useful for storing larger files or structured data.\n\n## Sample Application\n\n| Session / Local Storage    | IndexedDB |\n| -------- | ------- |\n| ![image](https://github.com/user-attachments/assets/32aa25af-08d2-4a3b-ad2d-8ea231c3e12d)  | ![image](https://github.com/user-attachments/assets/4dcf76ee-dd3d-436b-bf8f-c08f6fe7b25d)    |\n\n\n\n## How to Use\n\nCurrently, the library is under constant development. To use it, you can clone the repository and reference the project in your AvaloniaUI application or can install the nuget package.\n\nNuget Package: [AvaloniaWASM.Storage](https://www.nuget.org/packages/AvaloniaWASM.Storage/)\n\n1. Clone the repository:\n```bash\n   git clone https://github.com/SachiHarshitha/AvaloniaWASM.Storage.git\n ```\n\n2. Add a reference to the `AvaloniaWASM.Storage` project in your AvaloniaUI application (Both in the base and startup projects).\n\n3. Add the following section to the Browser startup project (File : xxxx.Browser.csproj).\n\n```xml\n\u003c!--Section :Direct Reference, Add following section if you refer the project directly--\u003e\n\t\u003cItemGroup\u003e\n\t\t\u003cJsFiles Include=\"..\\AvaloniaWASM.Storage\\wwwroot\\js\\**\\*.*\" /\u003e\n\t\u003c/ItemGroup\u003e\n\n\t\u003cTarget Name=\"CopyJsFilesBeforeBuild\" BeforeTargets=\"Build\"\u003e\n\t\t\u003cMessage Importance=\"high\" Text=\"Copying JS files to wwwroot...\" /\u003e\n\t\t\u003cCopy\n\t\t\tSourceFiles=\"@(JsFiles)\"\n\t\t\tDestinationFolder=\"$(MSBuildProjectDirectory)\\wwwroot\\js\\%(RecursiveDir)\"\n\t\t\tSkipUnchangedFiles=\"true\" /\u003e\n\t\u003c/Target\u003e\n\u003c!-- End Section--\u003e\n```\n\n4. Add the required JSScript loading to your crossplatform project (File : xxxx.csproj).\n\n```csharp\n\n\t# Option  1\n\t# Direct Reference, Add the following section to your App.cs file or wherever you initialize your application.\n\n\tif (OperatingSystem.IsBrowser())\n        {\n            await JSHost.ImportAsync(\"FuncLocalStorage\", \"/js/FuncLocalStorage.js\");\n            await JSHost.ImportAsync(\"FuncSessionStorage\", \"/js/FuncSessionStorage.js\");\n\t\t\tawait JSHost.ImportAsync(\"FuncIndexedDbFile\", \"/js/FuncIndexedDbFile.js\");\n\n        }\n\n\t..........\n\n\t# Option  2\n\t# For Dependency Injection, inject the services in your `App.cs` file or wherever you configure your services.\n\n\tservices.AddBrowserStorage();\n\n```\n\n5. Use the `LocalStorage` and `SessionStorage` classes to store and retrieve data in your AvaloniaUI application.\n```csharp\n\tusing AvaloniaWASM.Storage;\n\n\t.........\n\n\t# Initialize the storage services in your class or view model, if not dependecy Injection.\n\tprivate SessionStorageService _sessionStorageService = new SessionStorageService();\n\tprivate LocalStorageService _localStorageService = new LocalStorageService();\n\n\t..........\n\n\t# Session Storage Example\n\tawait _sessionStorageService.SetItemAsync(\"Session_Text\", ValueToSetSessionStorage);\n\tValueFromSessionStorage = await _sessionStorageService.GetItemAsync(\"Session_Text\");\n\n\t...........\n\t# Local Storage Example\n\tawait _localStorageService.SetItemAsync(\"Local_Text\", ValueToSetLocalStorage);\n\tValueFromLocalStorage = await _localStorageService.GetItemAsync(\"Local_Text\");\n\n\t...........\n\t# IndexedDB Example\n\tawait IndexedDbFileService.SaveFileAsync(dbName, storeName, fileName, _fileContent, \"text/plain\");\n\tvar filefromDB = await IndexedDbFileService.LoadFileAsBase64Async(dbName, storeName, fileName);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsachiharshitha%2Favaloniaui.browser.storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsachiharshitha%2Favaloniaui.browser.storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsachiharshitha%2Favaloniaui.browser.storage/lists"}