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 (
.razor files) for all component-based UI
- For complex components with injected services or significant logic, use the code-behind with
@inherits pattern: define a base class (e.g., DeviceDetailsBase : NexusPageComponentBase) and reference it with @inherits DeviceDetailsBase in the .razor file
- Keep small, presentational components inline with
@code { } blocks
- Create custom base components for shared concerns across pages — e.g., a
PageComponentBase that provides common injections (NavigationManager, AuthenticationState, ISnackbar) and helper methods (IsAuthenticatedAsync(), RedirectToLogin())
- Use
async/await for all non-blocking UI operations — never block on Task.Result or .Wait() inside components, as this deadlocks the synchronization context
Naming Conventions
- PascalCase for components, methods, properties, public members, and component parameters
- camelCase for private fields and local variables
- Prefix private fields with underscore (
_orderService)
- Prefix interfaces with
I (IOrderService)
- Name component files to match the component class (
OrderList.razor for OrderList)
Component Lifecycle
Blazor components follow a well-defined lifecycle. Understanding when each method runs prevents redundant work and subtle bugs.
| Method |
When it runs |
Typical use |
SetParametersAsync |
On every parameter update, before other lifecycle methods |
Low-level parameter interception (rarely overridden directly) |
OnInitialized / OnInitializedAsync |
Once when the component first initializes |
Initial data loading, one-time setup |
OnParametersSet / OnParametersSetAsync |
After parameter values are set (on init and every update) |
Reacting to parameter changes, recomputing derived state |
OnAfterRender / OnAfterRenderAsync |
After each render, with firstRender flag |
JS interop calls, DOM measurements, third-party library init |
Dispose / DisposeAsync |
When the component is removed from the render tree |
Unsubscribe from events, cancel CancellationTokenSource, release resources |
- Implement
IDisposable or IAsyncDisposable to clean up event subscriptions and cancellation tokens — leaked subscriptions cause memory leaks and ghost updates
- Use
firstRender in OnAfterRenderAsync to run one-time JS interop or DOM setup
- Avoid calling
StateHasChanged() inside OnInitializedAsync or OnParametersSetAsync — Blazor calls it automatically after these methods complete
Data Binding
- Use
@bind for two-way binding to input elements: <input @bind="searchText" />
- Use
@bind:event to control when the binding updates (e.g., @bind:event="oninput" for real-time updates vs the default onchange)
- Use
@bind:after to run logic after a bound value changes without writing a manual setter
- For component parameters, expose a
Value / ValueChanged pair to support @bind-Value from parent components:
[Parameter] public string Value { get; set; } = string.Empty;
[Parameter] public EventCallback<string> ValueChanged { get; set; }
Component Communication
- Parent to child: pass data via
[Parameter] properties
- Child to parent: use
EventCallback<T> to notify the parent of changes
- Deep tree sharing: use
[CascadingParameter] with <CascadingValue> to avoid prop-drilling through intermediate components
- Keep
EventCallback over Action/Func for event handling — EventCallback automatically triggers a re-render on the correct component and handles async delegates
Dependency Injection
In code-behind base classes, use [Inject] on properties. In .razor files, use @inject:
// Code-behind pattern (preferred for complex components)
[Inject] protected GatewayService GatewayService { get; set; }
[Inject] protected IDialogService DialogService { get; set; }
[Inject] protected ISnackbar SnackBarService { get; set; }
[Inject] protected NavigationManager Navigation { get; set; }
- Register services with the correct scope:
Scoped for per-circuit (Server) or per-user (WASM) services, Singleton for shared state and hub connections, Transient for stateless utilities
- Avoid injecting
Scoped services into Singleton services — this captures a stale instance (the captive dependency problem)
Separation of Concerns
- Components handle UI rendering and user interaction only
- Extract business logic into injectable services
- Use dedicated model or DTO classes for data transfer — do not pass entity or database models directly to components
- Isolate HTTP calls in typed service classes rather than calling
HttpClient directly from components
Modern C# Features
Leverage current C# language features for clarity and conciseness:
- Records for immutable data models and DTOs (
record OrderDto(int Id, string Name, decimal Total);)
- Pattern matching in event handlers and conditional rendering logic
- Global usings in
_Imports.razor for commonly used namespaces
- File-scoped namespaces in code-behind files
- Nullable reference types — enable project-wide and handle nullability explicitly in component parameters and service returns
Error Handling and Validation
Page and API Error Handling
- Wrap data-loading calls in try-catch within lifecycle methods and present user-friendly feedback via
ISnackbar:
try
{
await LoadDataAsync(cancellationToken);
}
catch (UnauthorizedAccessException)
{
RedirectToLogin();
}
catch (Exception ex)
{
SnackBarService.Add($"Failed to load data: {ex.Message}", Severity.Error);
}
- Catch
NavigationException separately — it is expected in Blazor Server when navigation aborts rendering
- Use
ErrorBoundary for catching unhandled rendering exceptions when appropriate
- Configure a global error handler page with
app.UseExceptionHandler("/Error")
Form and Input Patterns
- Use
EditForm with DataAnnotationsValidator for form-heavy scenarios with validation
- For search/filter UIs, use component library inputs (e.g.,
MudTextField, MudSelect) with debouncing:
<MudTextField DebounceInterval="500"
@bind-Value="SearchQuery"
Placeholder="Search..." />
Performance Optimization
Blazor re-renders components more often than you might expect. These patterns keep the UI responsive.
Reduce Unnecessary Renders
- Override
ShouldRender() and return false when the component output has not changed — this skips the entire diff and DOM patch cycle
- Use
@key on list items so Blazor can match existing elements by identity instead of recreating them on every render
- Mark child components with
@rendermode appropriately (Server vs WebAssembly vs Static SSR) based on interactivity needs
- Avoid allocating new objects (lambdas, collections, anonymous types) inside render logic — each allocation looks like a "change" to the diffing engine
Server vs WebAssembly Considerations
| Concern |
Blazor Server |
Blazor WebAssembly |
| Initial load |
Fast — only a small SignalR connection is established |
Slower — the .NET runtime and app assemblies download to the browser |
| Latency |
Every UI interaction is a SignalR round-trip |
No round-trip for UI logic; HTTP calls only for data |
| Scalability |
Each user holds a server circuit and memory |
Client-side — the server only serves APIs |
| Offline support |
None — requires a persistent connection |
Possible with service workers and local caching |
| Data access |
Direct access to server-side resources (databases, file system) |
Must go through HTTP APIs |
- On Server, minimize SignalR payload by keeping component state small and avoiding large objects in memory per circuit
- On WebAssembly, use lazy loading (
<Router>) to defer assembly downloads and reduce initial payload
- Use
IAsyncEnumerable streaming with Server to progressively render large datasets without loading everything into memory
Async Methods for API Calls
- Always use async methods (
GetFromJsonAsync, PostAsJsonAsync) for HTTP operations
- Provide a loading indicator while awaiting data to avoid a blank or stale UI
Efficient Event Handling
- Prefer
EventCallback<T> over raw delegates for component events — they batch render updates correctly
- Debounce high-frequency events (e.g., search-as-you-type) to avoid flooding the server or triggering excessive re-renders
Caching Strategies
Choose a caching approach based on the hosting model:
Blazor Server
- Use
IMemoryCache for fast, in-process caching of frequently accessed data
- Use a distributed cache (Redis, SQL Server) when running multiple server instances so all circuits share the same cached data
- Register caches as
Singleton so they survive across circuit lifetimes
Blazor WebAssembly
- Use
localStorage for persistent, cross-session data (user preferences, tokens)
- Use
sessionStorage for per-tab, session-scoped data
- Consider
Blazored.LocalStorage or Blazored.SessionStorage packages for a typed, async-friendly API
General Caching
- Cache API call responses when the data does not change frequently, and invalidate on relevant mutations
- Use cache-aside pattern: check cache first, fetch from source on miss, store result
State Management
Choose the right pattern based on complexity:
Global App State (StateContainer Pattern)
Use a scoped StateContainer service for app-wide state like theme, user preferences, or shared UI settings. Expose state via properties and notify components via events:
public class StateContainer
{
public bool IsDarkMode { get; private set; }
public event Action? OnThemeChange;
public void UseDarkMode(bool darkMode)
{
IsDarkMode = darkMode;
OnThemeChange?.Invoke();
}
}
Register as Scoped, inject into components, subscribe to events, call StateHasChanged() in the handler, and unsubscribe in Dispose.
Feature State (DataStateService Pattern)
For feature-specific state (device lists, search filters, real-time updates), create a dedicated scoped service that combines data caching with event notifications:
public class DataStateService : IDataStateService, IDisposable
{
public List<DeviceType> DeviceTypes { get; private set; } = [];
public DeviceSearchState SearchState { get; } = new();
public event Action? DeviceStateUpdated;
// ... fetch, cache, notify
}
Component-Level Persistence
Use [PersistentState] (.NET 10+) to automatically serialize/deserialize component state across navigations:
[PersistentState]
public List<Device>? Devices { get; set; }
Complex State
For larger applications where many unrelated components need coordinated state, consider Fluxor or Blazor-State for Redux-style unidirectional data flow.
WebAssembly Persistence
- Use
localStorage / sessionStorage (via Blazored.LocalStorage or similar) to persist state across page reloads in WASM apps
UI Component Libraries
When using a component library like MudBlazor, follow its conventions consistently:
- Use library layout components (
MudLayout, MudAppBar, MudDrawer, MudMainContent) for the application shell
- Use
IDialogService for modal dialogs and ISnackbar for toast notifications instead of custom implementations
- Use library data components (
MudTable, MudSelect, MudTextField) with their built-in features (sorting, paging, debouncing)
- Override library styles through CSS variables and a centralized override stylesheet rather than per-component hacks
- Wrap the app root with the library's theme provider for consistent theming and dark mode support
Real-Time Communication
For real-time features, use SignalR:
- Create a dedicated hub connection service registered as
Singleton for connection lifecycle management
- Subscribe to hub events in
DataStateService or a similar scoped service, and propagate changes via events that components subscribe to
- Handle connection drops gracefully with reconnection logic
API Integration
- Create a gateway service (API facade) that encapsulates all HTTP calls behind a typed interface — components inject this service rather than calling
HttpClient directly
- Use
IHttpClientFactory for HTTP client management with named or typed clients
- Handle errors with try-catch and surface user-friendly feedback via
ISnackbar rather than letting exceptions propagate to the UI
- Use
CancellationToken with HTTP calls so navigating away cancels in-flight requests
Streaming and Rendering
- Use
@attribute [StreamRendering] on pages for improved perceived performance — content renders progressively as data loads
- Show loading indicators while async data is pending
Testing
- Use bUnit for component-level testing — it renders components in a test context and lets you assert on markup, parameters, and events
- Use xUnit as the test framework and NSubstitute for mocking injected services
- Test component rendering, parameter changes, event callbacks, and lifecycle behavior
- Mock
NavigationManager, HttpClient, and custom services via bUnit's dependency injection
Security and Authentication
- Use Microsoft Entra ID (via
Microsoft.Identity.Web) for enterprise authentication, or ASP.NET Identity / JWT for other scenarios
- Use
AddCascadingAuthenticationState() to make auth state available throughout the component tree
- Access auth state in base components via
[CascadingParameter] protected Task<AuthenticationState>? AuthenticationStateTask
- Protect pages with
[Authorize] attribute and use <AuthorizeView> / <AuthorizeRouteView> for conditional rendering
- Use a
BearerTokenHandler to automatically attach JWT tokens to downstream API calls
- Never store secrets or sensitive tokens in WebAssembly client code — it runs entirely in the browser and is fully inspectable
1---2name: blazor-conventions3description: >4 Best practices and conventions for Blazor application development including Razor component structure,5 component lifecycle methods (OnInitializedAsync, OnParametersSetAsync), data binding, state management6 patterns, Server vs WebAssembly optimization, caching strategies, and error handling with ErrorBoundary.7 Use this skill whenever writing, reviewing, or refactoring Blazor components or pages — including when8 the user mentions Razor components, Blazor Server, Blazor WebAssembly (WASM), render optimization,9 cascading parameters, component parameters, or Blazor forms and validation, even if they do not10 explicitly say "Blazor best practices."11user-invocable: false12metadata:13 source: https://skillmd.com/skills/atc-net/blazor-conventions14---1516# Blazor Development Conventions1718Apply these practices when writing, reviewing, or refactoring Blazor applications.1920## Code Style and Structure2122- Write idiomatic Blazor and C# code that follows established .NET conventions23- Use Razor Components (`.razor` files) for all component-based UI24- For complex components with injected services or significant logic, use the **code-behind with `@inherits`** pattern: define a base class (e.g., `DeviceDetailsBase : NexusPageComponentBase`) and reference it with `@inherits DeviceDetailsBase` in the `.razor` file25- Keep small, presentational components inline with `@code { }` blocks26- Create **custom base components** for shared concerns across pages — e.g., a `PageComponentBase` that provides common injections (`NavigationManager`, `AuthenticationState`, `ISnackbar`) and helper methods (`IsAuthenticatedAsync()`, `RedirectToLogin()`)27- Use `async`/`await` for all non-blocking UI operations — never block on `Task.Result` or `.Wait()` inside components, as this deadlocks the synchronization context2829## Naming Conventions3031- **PascalCase** for components, methods, properties, public members, and component parameters32- **camelCase** for private fields and local variables33- Prefix private fields with underscore (`_orderService`)34- Prefix interfaces with `I` (`IOrderService`)35- Name component files to match the component class (`OrderList.razor` for `OrderList`)3637## Component Lifecycle3839Blazor components follow a well-defined lifecycle. Understanding when each method runs prevents redundant work and subtle bugs.4041| Method | When it runs | Typical use |42|---|---|---|43| `SetParametersAsync` | On every parameter update, before other lifecycle methods | Low-level parameter interception (rarely overridden directly) |44| `OnInitialized` / `OnInitializedAsync` | Once when the component first initializes | Initial data loading, one-time setup |45| `OnParametersSet` / `OnParametersSetAsync` | After parameter values are set (on init and every update) | Reacting to parameter changes, recomputing derived state |46| `OnAfterRender` / `OnAfterRenderAsync` | After each render, with `firstRender` flag | JS interop calls, DOM measurements, third-party library init |47| `Dispose` / `DisposeAsync` | When the component is removed from the render tree | Unsubscribe from events, cancel `CancellationTokenSource`, release resources |4849- Implement `IDisposable` or `IAsyncDisposable` to clean up event subscriptions and cancellation tokens — leaked subscriptions cause memory leaks and ghost updates50- Use `firstRender` in `OnAfterRenderAsync` to run one-time JS interop or DOM setup51- Avoid calling `StateHasChanged()` inside `OnInitializedAsync` or `OnParametersSetAsync` — Blazor calls it automatically after these methods complete5253## Data Binding5455- Use `@bind` for two-way binding to input elements: `<input @bind="searchText" />`56- Use `@bind:event` to control when the binding updates (e.g., `@bind:event="oninput"` for real-time updates vs the default `onchange`)57- Use `@bind:after` to run logic after a bound value changes without writing a manual setter58- For component parameters, expose a `Value` / `ValueChanged` pair to support `@bind-Value` from parent components:5960```razor61[Parameter] public string Value { get; set; } = string.Empty;62[Parameter] public EventCallback<string> ValueChanged { get; set; }63```6465## Component Communication6667- **Parent to child**: pass data via `[Parameter]` properties68- **Child to parent**: use `EventCallback<T>` to notify the parent of changes69- **Deep tree sharing**: use `[CascadingParameter]` with `<CascadingValue>` to avoid prop-drilling through intermediate components70- Keep `EventCallback` over `Action`/`Func` for event handling — `EventCallback` automatically triggers a re-render on the correct component and handles async delegates7172## Dependency Injection7374In code-behind base classes, use `[Inject]` on properties. In `.razor` files, use `@inject`:7576```csharp77// Code-behind pattern (preferred for complex components)78[Inject] protected GatewayService GatewayService { get; set; }79[Inject] protected IDialogService DialogService { get; set; }80[Inject] protected ISnackbar SnackBarService { get; set; }81[Inject] protected NavigationManager Navigation { get; set; }82```8384- Register services with the correct scope: `Scoped` for per-circuit (Server) or per-user (WASM) services, `Singleton` for shared state and hub connections, `Transient` for stateless utilities85- Avoid injecting `Scoped` services into `Singleton` services — this captures a stale instance (the captive dependency problem)8687## Separation of Concerns8889- Components handle UI rendering and user interaction only90- Extract business logic into injectable services91- Use dedicated model or DTO classes for data transfer — do not pass entity or database models directly to components92- Isolate HTTP calls in typed service classes rather than calling `HttpClient` directly from components9394## Modern C# Features9596Leverage current C# language features for clarity and conciseness:9798- **Records** for immutable data models and DTOs (`record OrderDto(int Id, string Name, decimal Total);`)99- **Pattern matching** in event handlers and conditional rendering logic100- **Global usings** in `_Imports.razor` for commonly used namespaces101- **File-scoped namespaces** in code-behind files102- **Nullable reference types** — enable project-wide and handle nullability explicitly in component parameters and service returns103104## Error Handling and Validation105106### Page and API Error Handling107108- Wrap data-loading calls in try-catch within lifecycle methods and present user-friendly feedback via `ISnackbar`:109110```csharp111try112{113 await LoadDataAsync(cancellationToken);114}115catch (UnauthorizedAccessException)116{117 RedirectToLogin();118}119catch (Exception ex)120{121 SnackBarService.Add($"Failed to load data: {ex.Message}", Severity.Error);122}123```124125- Catch `NavigationException` separately — it is expected in Blazor Server when navigation aborts rendering126- Use `ErrorBoundary` for catching unhandled rendering exceptions when appropriate127- Configure a global error handler page with `app.UseExceptionHandler("/Error")`128129### Form and Input Patterns130131- Use `EditForm` with `DataAnnotationsValidator` for form-heavy scenarios with validation132- For search/filter UIs, use component library inputs (e.g., `MudTextField`, `MudSelect`) with debouncing:133134```razor135<MudTextField DebounceInterval="500"136 OnDebounceIntervalElapsed="ApplyFilters"137 @bind-Value="SearchQuery"138 Placeholder="Search..." />139```140141## Performance Optimization142143Blazor re-renders components more often than you might expect. These patterns keep the UI responsive.144145### Reduce Unnecessary Renders146147- Override `ShouldRender()` and return `false` when the component output has not changed — this skips the entire diff and DOM patch cycle148- Use `@key` on list items so Blazor can match existing elements by identity instead of recreating them on every render149- Mark child components with `@rendermode` appropriately (Server vs WebAssembly vs Static SSR) based on interactivity needs150- Avoid allocating new objects (lambdas, collections, anonymous types) inside render logic — each allocation looks like a "change" to the diffing engine151152### Server vs WebAssembly Considerations153154| Concern | Blazor Server | Blazor WebAssembly |155|---|---|---|156| Initial load | Fast — only a small SignalR connection is established | Slower — the .NET runtime and app assemblies download to the browser |157| Latency | Every UI interaction is a SignalR round-trip | No round-trip for UI logic; HTTP calls only for data |158| Scalability | Each user holds a server circuit and memory | Client-side — the server only serves APIs |159| Offline support | None — requires a persistent connection | Possible with service workers and local caching |160| Data access | Direct access to server-side resources (databases, file system) | Must go through HTTP APIs |161162- On Server, minimize SignalR payload by keeping component state small and avoiding large objects in memory per circuit163- On WebAssembly, use lazy loading (`<Router OnNavigateAsync="OnNavigateAsync">`) to defer assembly downloads and reduce initial payload164- Use `IAsyncEnumerable` streaming with Server to progressively render large datasets without loading everything into memory165166### Async Methods for API Calls167168- Always use async methods (`GetFromJsonAsync`, `PostAsJsonAsync`) for HTTP operations169- Provide a loading indicator while awaiting data to avoid a blank or stale UI170171### Efficient Event Handling172173- Prefer `EventCallback<T>` over raw delegates for component events — they batch render updates correctly174- Debounce high-frequency events (e.g., search-as-you-type) to avoid flooding the server or triggering excessive re-renders175176## Caching Strategies177178Choose a caching approach based on the hosting model:179180### Blazor Server181182- Use `IMemoryCache` for fast, in-process caching of frequently accessed data183- Use a distributed cache (Redis, SQL Server) when running multiple server instances so all circuits share the same cached data184- Register caches as `Singleton` so they survive across circuit lifetimes185186### Blazor WebAssembly187188- Use `localStorage` for persistent, cross-session data (user preferences, tokens)189- Use `sessionStorage` for per-tab, session-scoped data190- Consider `Blazored.LocalStorage` or `Blazored.SessionStorage` packages for a typed, async-friendly API191192### General Caching193194- Cache API call responses when the data does not change frequently, and invalidate on relevant mutations195- Use cache-aside pattern: check cache first, fetch from source on miss, store result196197## State Management198199Choose the right pattern based on complexity:200201### Global App State (StateContainer Pattern)202203Use a scoped `StateContainer` service for app-wide state like theme, user preferences, or shared UI settings. Expose state via properties and notify components via events:204205```csharp206public class StateContainer207{208 public bool IsDarkMode { get; private set; }209 public event Action? OnThemeChange;210211 public void UseDarkMode(bool darkMode)212 {213 IsDarkMode = darkMode;214 OnThemeChange?.Invoke();215 }216}217```218219Register as `Scoped`, inject into components, subscribe to events, call `StateHasChanged()` in the handler, and unsubscribe in `Dispose`.220221### Feature State (DataStateService Pattern)222223For feature-specific state (device lists, search filters, real-time updates), create a dedicated scoped service that combines data caching with event notifications:224225```csharp226public class DataStateService : IDataStateService, IDisposable227{228 public List<DeviceType> DeviceTypes { get; private set; } = [];229 public DeviceSearchState SearchState { get; } = new();230 public event Action? DeviceStateUpdated;231 // ... fetch, cache, notify232}233```234235### Component-Level Persistence236237Use `[PersistentState]` (.NET 10+) to automatically serialize/deserialize component state across navigations:238239```csharp240[PersistentState]241public List<Device>? Devices { get; set; }242```243244### Complex State245246For larger applications where many unrelated components need coordinated state, consider Fluxor or Blazor-State for Redux-style unidirectional data flow.247248### WebAssembly Persistence249250- Use `localStorage` / `sessionStorage` (via `Blazored.LocalStorage` or similar) to persist state across page reloads in WASM apps251252## UI Component Libraries253254When using a component library like **MudBlazor**, follow its conventions consistently:255256- Use library layout components (`MudLayout`, `MudAppBar`, `MudDrawer`, `MudMainContent`) for the application shell257- Use `IDialogService` for modal dialogs and `ISnackbar` for toast notifications instead of custom implementations258- Use library data components (`MudTable`, `MudSelect`, `MudTextField`) with their built-in features (sorting, paging, debouncing)259- Override library styles through **CSS variables** and a centralized override stylesheet rather than per-component hacks260- Wrap the app root with the library's theme provider for consistent theming and dark mode support261262## Real-Time Communication263264For real-time features, use **SignalR**:265266- Create a dedicated hub connection service registered as `Singleton` for connection lifecycle management267- Subscribe to hub events in `DataStateService` or a similar scoped service, and propagate changes via events that components subscribe to268- Handle connection drops gracefully with reconnection logic269270## API Integration271272- Create a **gateway service** (API facade) that encapsulates all HTTP calls behind a typed interface — components inject this service rather than calling `HttpClient` directly273- Use `IHttpClientFactory` for HTTP client management with named or typed clients274- Handle errors with try-catch and surface user-friendly feedback via `ISnackbar` rather than letting exceptions propagate to the UI275- Use `CancellationToken` with HTTP calls so navigating away cancels in-flight requests276277## Streaming and Rendering278279- Use `@attribute [StreamRendering]` on pages for improved perceived performance — content renders progressively as data loads280- Show loading indicators while async data is pending281282## Testing283284- Use **bUnit** for component-level testing — it renders components in a test context and lets you assert on markup, parameters, and events285- Use **xUnit** as the test framework and **NSubstitute** for mocking injected services286- Test component rendering, parameter changes, event callbacks, and lifecycle behavior287- Mock `NavigationManager`, `HttpClient`, and custom services via bUnit's dependency injection288289## Security and Authentication290291- Use **Microsoft Entra ID** (via `Microsoft.Identity.Web`) for enterprise authentication, or ASP.NET Identity / JWT for other scenarios292- Use `AddCascadingAuthenticationState()` to make auth state available throughout the component tree293- Access auth state in base components via `[CascadingParameter] protected Task<AuthenticationState>? AuthenticationStateTask`294- Protect pages with `[Authorize]` attribute and use `<AuthorizeView>` / `<AuthorizeRouteView>` for conditional rendering295- Use a `BearerTokenHandler` to automatically attach JWT tokens to downstream API calls296- Never store secrets or sensitive tokens in WebAssembly client code — it runs entirely in the browser and is fully inspectable