Tempest.Blazor 1.0.0-beta.2

This is a prerelease version of Tempest.Blazor.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Tempest.Blazor --version 1.0.0-beta.2
                    
NuGet\Install-Package Tempest.Blazor -Version 1.0.0-beta.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tempest.Blazor" Version="1.0.0-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tempest.Blazor" Version="1.0.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Tempest.Blazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tempest.Blazor --version 1.0.0-beta.2
                    
#r "nuget: Tempest.Blazor, 1.0.0-beta.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tempest.Blazor@1.0.0-beta.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tempest.Blazor&version=1.0.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tempest.Blazor&version=1.0.0-beta.2&prerelease
                    
Install as a Cake Tool

Tempest

Component-owned state for Blazor. Your component keeps its state. You write plain private members; the generator emits one state twin per member — everything interesting lives behind {Name}State.

No store. No reducers. No actions folder. Three attributes and a bus.

// Program.cs
builder.Services.AddTempest();
@inherits StatefulComponent

@if (LoadCartState.IsLoading) { <p>Loading…</p> }
else
{
    <ul>@foreach (var item in _items) { <li>@item.Name</li> }</ul>
    <button @onclick="LoadCartState.TryExecute">Refresh</button>
}

@code {
    private List<CartItem> _items = [];

    public record ClearCart();          // the component's public doorbell panel

    [Command]                           // → LoadCartState : CommandState
    public async Task LoadCart()
        => _items = await Api.GetCartAsync();

    [Event]                             // rung from anywhere via the bus
    private void OnClearCart(ClearCart _) => _items.Clear();
}

Trigger from anywhere — no reference to the component needed:

Bus.Publish<CartComponent.ClearCart>();

What you get per [Command]

One generated property, {Name}State, holding the whole lifecycle:

Member Purpose
IsLoading true while the method runs; re-renders on both edges
IsError / Error last exception caught by TryExecute(), cleared on the next run
Execute() runs the lifecycle, exceptions propagate
TryExecute() never throws — the exception lands in Error
ClearError() dismisses the error
Result / HasResult on value-returning commands: the last successful value

Every return type participates: Task / ValueTask / void generate a plain CommandState; Task<T> / ValueTask<T> / plain T generate a CommandState<T> whose Result holds the last successful value — render it directly instead of copying into a field:

[Command]                                   // → LoadTodosState : CommandState<List<TodoItem>>
private Task<List<TodoItem>> LoadTodos(CancellationToken ct) => Api.GetTodosAsync(ct);

// markup: @foreach (var todo in LoadTodosState.Result ?? []) { ... }

Declare an optional trailing CancellationToken on the method for latest-wins cancellation: re-executing while a run is in flight cancels it, and a stale result — success or failure — is discarded instead of overwriting the newer one. Type into a search box faster than the API answers and the response for "r" can never overwrite the one for "re".

[Command]
private Task<TodoPage> LoadTodos(CancellationToken ct) => Api.SearchAsync(_search, ct);

[Event, Command] methods get an EventCommandState<TEvent> that takes the event record: ApplyCouponState.TryExecute(e). Bus-triggered runs always go through TryExecute, so a publish can never blow up in the publisher.

What you get per [Reactive]

Mark a private field and the generator emits its {PascalCase}State twin — a ReactiveState<T> the markup binds and shared components can take as a parameter:

<input @bind="SearchTextState.Value" @bind:event="oninput" />
Member Purpose
Value change-check → assign → re-render → ring the On{Name}Changed hook
SetSilently(v) change-check → assign → re-render — no hook
Initial / IsDirty / Reset() the field's starting value, drift check, and way back

React to changes by implementing the partial hook — the generator declares it, you write the body, and the C# compiler enforces the pairing (rename the field without the hook and the build breaks):

[Reactive]
private string _searchText = "";

private partial Task OnSearchTextChanged(string value)
{
    PageState.SetSilently(1);                    // adjust siblings without re-triggering
    return SearchUsersState.TryExecute();        // orchestration is C#, not configuration
}

The hook adapts to what you write: implement partial void for a synchronous reaction, partial Task for async work — or implement nothing and the property just re-renders.

Tempest handles reactivity only — when values change (debouncing, on-input vs on-blur) is the input layer's job. Put a debounced input in front; the state reacts to whatever arrives.

Guardrails

Misuse is caught at compile time, mostly by the C# compiler itself: an orphaned or misspelled hook is a build error (CS8795), and the generator adds diagnostics for handler shape (TEM001), missing StatefulComponent base (TEM002), command parameters (TEM003), invalid [Reactive] fields (TEM007) and non-partial hooks (TEM008).

State lives in the component. Nobody reads it but you.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-beta.6 235 7/24/2026
1.0.0-beta.5 90 7/23/2026
1.0.0-beta.3 85 7/19/2026
1.0.0-beta.2 101 7/18/2026
1.0.0-beta.1 93 7/12/2026

Breaking: flat generated members (IsLoading{Name}, {Name}Error, {Name}Command, Try{Name}Command) are replaced by one {Name}State property per member.
- [Command] generates CommandState (Task/ValueTask/void) or CommandState<T> with Result/HasResult (Task<T>/ValueTask<T>/T).
- [Event, Command] generates EventCommandState<TEvent>.
- Latest-wins cancellation via an optional trailing CancellationToken parameter.
- New [Reactive] fields generate a ReactiveState<T> twin (Value/SetSilently/Initial/IsDirty/Reset) with an optional partial On{Name}Changed(T value) hook.