blazor
Maintain Blazor Server components using BookStore conventions, reactive queries, and MudBlazor UI controls.
Install
mkdir -p .claude/skills/blazor && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14278" && unzip -o skill.zip -d .claude/skills/blazor && rm skill.zipInstalls to .claude/skills/blazor
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Write, review, and fix Blazor Server components in the BookStore project — covering render modes (InteractiveServer), lifecycle with IDisposable cleanup, DI via @inject/[Inject], ReactiveQuery<T> for SSE-driven data loading, MudBlazor forms/dialogs/tables, tenant-aware services, and AuthorizeView guards. Trigger whenever the user writes, reviews, or asks about .razor files, adding a page or component, ReactiveQuery, MudForm/MudTable/MudDialog, real-time UI updates from SSE, tenant-aware components, optimistic updates in the frontend, authorization guards in pages, or BookStore.Web — even if they don't say "Blazor" explicitly.Key capabilities
- →Write Blazor Server components following BookStore conventions
- →Implement reactive data loading using `ReactiveQuery<T>`
- →Manage component lifecycle with `IDisposable` cleanup
- →Integrate MudBlazor forms, dialogs, and tables
- →Authorize components using `AuthorizeView` and `[Authorize]`
How it works
It guides the creation of Blazor Server components within the BookStore project, focusing on `InteractiveServer` render mode, `IDisposable` cleanup, `ReactiveQuery<T>` for data, MudBlazor for UI, and `AuthorizeView` for authorization.
Inputs & outputs
When to use blazor
- →Implement reactive data loading
- →Add MudBlazor forms or tables
- →Manage IDisposable cleanup
- →Authorize components via AuthorizeView
About this skill
Blazor Components — BookStore Conventions
BookStore's Blazor Server frontend is built around a few key abstractions: ReactiveQuery<T> for reactive data fetching, BookStoreEventsService for SSE subscriptions, and MudBlazor for all UI components. Getting these patterns right avoids the most common failure modes: missing IDisposable cleanups, forgetting SSE event propagation, and bypassing the Refit client layer.
Quick Reference
| Topic | Read this file |
|---|---|
| Component skeleton, render mode, DI, lifecycle, IDisposable | references/component-anatomy.md |
ReactiveQuery<T>, SSE subscriptions, loading states, optimistic updates | references/reactive-query.md |
| MudForm, MudTable (server-side), dialogs, ETags, search debounce | references/forms-dialogs.md |
| AuthorizeView, [Authorize], TenantService, tenant-aware components | references/auth-tenant.md |
| Common mistakes and anti-patterns | references/pitfalls.md |
Related skills: ../bunit/SKILL.md (testing Blazor components), ../aspnet-sse/SKILL.md (SSE backend implementation), ../aspnet-hybrid-cache/SKILL.md (cache invalidation wiring).
Canonical Page Skeleton
This is the shape every stateful, data-loading page follows. Read references/component-anatomy.md for variants and explanation.
@page "/admin/widgets"
@rendermode InteractiveServer
@implements IDisposable
@inject IWidgetsClient WidgetsClient
@inject BookStoreEventsService EventsService
@inject QueryInvalidationService InvalidationService
@inject ISnackbar Snackbar
<PageTitle>Widgets</PageTitle>
@if (_query?.IsLoading == true && _query.Data == null)
{
<MudSkeleton />
}
else if (_query?.IsError == true)
{
<MudAlert Severity="Severity.Error">@_query.Error</MudAlert>
}
else
{
@* render _query.Data *@
}
@code {
[Inject] private ILogger<Widgets> Logger { get; set; } = default!;
private ReactiveQuery<IReadOnlyList<WidgetDto>>? _query;
private readonly CancellationTokenSource _cts = new();
private bool _disposed;
protected override async Task OnInitializedAsync()
{
EventsService.StartListening();
EventsService.OnNotificationReceived += HandleNotification;
_query = new ReactiveQuery<IReadOnlyList<WidgetDto>>(
queryFn: ct => WidgetsClient.GetWidgetsAsync(ct),
eventsService: EventsService,
invalidationService: InvalidationService,
queryKeys: ["Widgets"],
onStateChanged: () => InvokeAsync(StateHasChanged),
logger: Logger);
await _query.LoadAsync(cancellationToken: _cts.Token);
}
private async void HandleNotification(IDomainEventNotification notification)
{
if (notification is PingNotification) return;
if (InvalidationService.ShouldInvalidate(notification, ["Widgets"]))
await InvokeAsync(async () => { await _query!.LoadAsync(silent: true, _cts.Token); });
}
public void Dispose()
{
if (_disposed) return;
_disposed = true;
_cts.Cancel();
_cts.Dispose();
_query?.Dispose();
EventsService.OnNotificationReceived -= HandleNotification;
}
}
Rules at a Glance
- All stateful pages declare
@rendermode InteractiveServer; dialogs/shared components inherit it - Every SSE subscriber must
@implements IDisposableand unsubscribe inDispose() - Data loading uses
ReactiveQuery<T>— never rawawait Client.GetAsync()inOnInitializedAsyncwithout reactive wrapping - Always use injected Refit clients (
IBookStoreClientinterfaces) — never rawHttpClient - New query keys (e.g.,
"Widgets") must be registered inQueryInvalidationServiceto receive SSE-driven invalidation - UI mutations go through
CatalogService/AdminServicefor optimistic update orchestration; write results directly in the page only for simple admin flows - Forms use MudBlazor's
MudForm/MudTextField— notEditContext/DataAnnotations
Common Mistakes
See references/pitfalls.md for detailed before/after code. Quick list:
- Missing IDisposable → SSE events still fire after navigation, causing exceptions on disposed components
- Missing
QueryInvalidationServicemapping → SSE arrives but UI never refreshes - Calling
StateHasChanged()from a non-Blazor thread → useInvokeAsync(StateHasChanged)insideHandleNotification - Calling HttpClient directly → bypasses TenantHeaderHandler and auth chain; always use Refit interfaces
- Business logic in .razor → move to
Services/or backing classes async voidevent handler withouttry/catch→ unhandled exceptions crash the circuit; add error handling or useInvokeAsync<Task>
When not to use it
- →When working on Blazor WebAssembly projects
- →When the project does not follow BookStore's specific Blazor conventions
- →When using a different UI framework than MudBlazor
Limitations
- →It is specific to the BookStore project's Blazor architecture.
- →It focuses on Blazor Server components.
- →It relies on MudBlazor for UI components.
How it compares
This skill provides specific architectural patterns and conventions for Blazor Server components within the BookStore project, including reactive data fetching and MudBlazor integration, rather than general Blazor development.
Compared to similar skills
blazor side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| blazor (this skill) | 0 | 4mo | No flags | Intermediate |
| component-development | 1 | 4mo | Review | Intermediate |
| avalonia-viewmodels-zafiro | 0 | 6mo | No flags | Intermediate |
| syncfusion-blazor-toolkit-calendars | 0 | 1mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by aalmada
View all by aalmada →You might also like
component-development
FritzAndFriends
Guidance for creating Blazor components that emulate ASP.NET Web Forms controls. Use this when implementing new components or extending existing ones in the BlazorWebFormsComponents library.
avalonia-viewmodels-zafiro
davila7
Optimal ViewModel and Wizard creation patterns for Avalonia using Zafiro and ReactiveUI.
syncfusion-blazor-toolkit-calendars
syncfusion
Build and customize calendar-based components in Syncfusion Blazor Toolkit. Covers Calendar, DatePicker, DateTimePicker, and TimePicker. Use when implementing date/time selection features, handling date range restriction, formatting dates, managing calendar events, validating dates, or customizing c
syncfusion-blazor-toolkit-buttons
syncfusion
Implement interactive Blazor button components with Syncfusion Toolkit. Covers SfButton, SfButtonGroup with styling and accessibility.
dotnet-blazor
managedcode
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and hosting choices.
dotnet-spectre-console
rudironsoni
>-