blazor-conventions
Installation
SKILL.md
Blazor Development Conventions
Apply these practices when writing, reviewing, or refactoring Blazor applications.
Code Style and Structure
- Write idiomatic Blazor and C# code that follows established .NET conventions
- Use Razor Components (
.razorfiles) for all component-based UI - For complex components with injected services or significant logic, use the code-behind with
@inheritspattern: define a base class (e.g.,DeviceDetailsBase : NexusPageComponentBase) and reference it with@inherits DeviceDetailsBasein the.razorfile - Keep small, presentational components inline with
@code { }blocks - Create custom base components for shared concerns across pages — e.g., a
PageComponentBasethat provides common injections (NavigationManager,AuthenticationState,ISnackbar) and helper methods (IsAuthenticatedAsync(),RedirectToLogin()) - Use
async/awaitfor all non-blocking UI operations — never block onTask.Resultor.Wait()inside components, as this deadlocks the synchronization context