Janar.MAUIStorage
1.0.3
dotnet add package Janar.MAUIStorage --version 1.0.3
NuGet\Install-Package Janar.MAUIStorage -Version 1.0.3
<PackageReference Include="Janar.MAUIStorage" Version="1.0.3" />
<PackageVersion Include="Janar.MAUIStorage" Version="1.0.3" />
<PackageReference Include="Janar.MAUIStorage" />
paket add Janar.MAUIStorage --version 1.0.3
#r "nuget: Janar.MAUIStorage, 1.0.3"
#:package Janar.MAUIStorage@1.0.3
#addin nuget:?package=Janar.MAUIStorage&version=1.0.3
#tool nuget:?package=Janar.MAUIStorage&version=1.0.3
Janar MAUIStorage (LocalStorage + SessionStorage)
A lightweight, production-ready MAUI library for browser storage.
Supports:
- LocalStorage
- SessionStorage
- Expiration support (like cookies)
- Optional encryption (ASP.NET Data Protection)
- Strongly typed APIs
- Clean Dependency Injection
☕ Support
If you find this package helpful, please consider supporting me:
🚀 Features
- Simple dependency injection
- Fully async API
- LocalStorage support
- SessionStorage support
- Expiration per key
- Optional encryption using ASP.NET Data Protection
- Automatic JSON serialization/deserialization
- Safe error handling
- Production-ready structure
📦 Installation
Install via NuGet:
dotnet add package Janar.MAUIStorage
⚙️ Setup
Register services in Program.cs:
builder.Services.AddMAUIStorage(options =>
{
options.UseEncryption = true; // optional
});
🧠 Usage
Inject services into MAUI components:
@inject ILocalStorageService LocalStorage
@inject ISessionStorageService SessionStorage
💾 LocalStorage Usage
Store data
await LocalStorage.SetItemAsync("user", user);
Store with expiration
await LocalStorage.SetItemAsync("user", user, TimeSpan.FromMinutes(30));
Get data
var user = await LocalStorage.GetItemAsync<User>("user");
Remove data
await LocalStorage.RemoveItemAsync("user");
Check existence
bool exists = await LocalStorage.ExistsAsync("user");
Clear all
await LocalStorage.ClearAsync();
📂 SessionStorage Usage
SessionStorage works exactly the same as LocalStorage:
await SessionStorage.SetItemAsync("token", token);
var token = await SessionStorage.GetItemAsync<string>("token");
await SessionStorage.RemoveItemAsync("token");
await SessionStorage.ClearAsync();
🔐 Encryption
When enabled:
options.UseEncryption = true;
All data stored in browser is automatically encrypted using ASP.NET Data Protection API.
No changes required in application code.
⏱ Expiration Support
You can set expiration per item:
await LocalStorage.SetItemAsync("key", value, TimeSpan.FromMinutes(10));
After expiration:
- Data is automatically removed
- GetItemAsync returns default value
🏗 Architecture
This library uses:
- JavaScript Interop for browser storage
- JSON serialization for type safety
- ASP.NET Data Protection for encryption
- Dependency Injection for clean usage
🧩 Supported Data Types
- Primitive types (string, int, bool, etc.)
- Complex objects (POCO classes)
- Lists and collections
- Custom models
⚠️ Notes
- Works only in browser environment
- MAUI Blazor Hybrid fully supported
- Encryption requires Microsoft.AspNetCore.DataProtection
- Keys are case-sensitive
📦 Versioning
| Change Type | Version |
|---|---|
| Breaking | 1.0.0 |
| Bug Fix | 1.0.2 |
| Updated Pkg | 1.0.3 |
📄 License
MIT License
❤️ Author
Built with love for MAUI developers.
Thank you for using Janar.MAUIStorage!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Options (>= 10.0.8)
- Microsoft.Maui.Essentials (>= 10.0.70)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
