RevalQuery.Blazor
0.1.2
See the version list below for details.
dotnet add package RevalQuery.Blazor --version 0.1.2
NuGet\Install-Package RevalQuery.Blazor -Version 0.1.2
<PackageReference Include="RevalQuery.Blazor" Version="0.1.2" />
<PackageVersion Include="RevalQuery.Blazor" Version="0.1.2" />
<PackageReference Include="RevalQuery.Blazor" />
paket add RevalQuery.Blazor --version 0.1.2
#r "nuget: RevalQuery.Blazor, 0.1.2"
#:package RevalQuery.Blazor@0.1.2
#addin nuget:?package=RevalQuery.Blazor&version=0.1.2
#tool nuget:?package=RevalQuery.Blazor&version=0.1.2
RevalQuery
A high-performance, Result-oriented data fetching library for Blazor.
Heavily inspired by TanStack Query, BlazorQ brings a professional-grade state management and caching layer to .NET 8+. It is designed for developers who value type safety, explicit error handling via the Result Pattern, and architecture that works across both Blazor WebAssembly and Blazor Server.
📦 Installation
Register the core services in your Program.cs.
//Program.cs
builder.Services.AddScoped<QueryClient>();
builder.Services.AddSingleton<QueryPluginsPipeline>();
🏗 Component Integration
Before using the following functions, your components must inherit from the base class:
@inherits BlazorQ.QueryComponentBase
🔍 Using Queries (UseQuery)
The UseQuery method allows you to observe a piece of data.
Stateless Handlers
Handlers must be stateless. Using the static keyword on your lambda is the best way to enforce this; it prevents
the closure from capturing component-level variables and ensures the compiler helps you stay safe.
private IQueryState<BasketItem?> quantityQuery => UseQuery(
QueryOptionsFactory.Create
(
key: ("basket-count", itemId),
handler: static async ctx =>
{
// Access services via the context ServiceProvider
var basketService = ctx.ServiceProvider.GetRequiredService<IBasketService>();
var item = await basketService.GetItem(ctx.Key.itemId);
return QueryResult.Success(item);
},
onSuccess: async (basketItem) =>
{
Console.WriteLine($"Fetched quantity: {basketItem?.Quantity}");
},
enabled: OperatingSystem.IsBrowser() // Only fetch on the client side
),
cancellationTokenSource
);
💡 Pro Tip: For better reusability and cleaner components, define your
QueryOptionsin a static factory class ( e.g.,BasketQueries.GetItemOptions(itemId)).
Stateless Validation (Highly Recommended)
To enforce architectural purity, use the stateless validation plugin during development. This ensures your handlers don't accidentally capture external state, which can lead to memory leaks or stale closures.
//Program.cs
if (builder.Environment.IsDevelopment())
{
// Throws errors at runtime if handlers capture state
builder.Services.AddSingleton<IQueryPlugin, QueryPluginHandlersStatelessValidation>();
}
⚡ Mutations
Unlike Queries, Mutations are used for server-side actions (Create/Update/Delete). These can be stateful and are the
recommended place to perform cache invalidation using the QueryClient.
private IMutationState<string, Task> addItemMutation => UseMutation(
MutationOptionsFactory.Create<string, Task>
(
handler: async (ctx) =>
{
var basketService = ctx.ServiceProvider.GetRequiredService<IBasketService>();
var queryClient = ctx.ServiceProvider.GetRequiredService<QueryClient>();
await basketService.AddItem(new(ctx.Params, 1));
// Invalidate specific cache keys to trigger re-fetches
queryClient.Invalidate(("basket-count", ctx.Params));
return Task.CompletedTask;
}
)
);
🛠 Features
Callbacks & Lifecycle
Queries support lifecycle callbacks (onSuccess, onError, onSettled). These allow you to trigger
side effects—like Toast notifications or logging—without polluting your UI logic.
Multi-Targeting
BlazorQ is built to target .NET 8, .NET 9 and .NET 10 (2026 Ready).
⚠️ Dev Release Note
This is a development release. The API is subject to change.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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.AspNetCore.Components (>= 10.0.2)
- RevalQuery.Core (>= 0.1.2)
-
net8.0
- Microsoft.AspNetCore.Components (>= 8.0.0)
- RevalQuery.Core (>= 0.1.2)
-
net9.0
- Microsoft.AspNetCore.Components (>= 9.0.0)
- RevalQuery.Core (>= 0.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.