TimeWarp.State 12.0.0-beta.17

Prefix Reserved
This is a prerelease version of TimeWarp.State.
dotnet add package TimeWarp.State --version 12.0.0-beta.17
                    
NuGet\Install-Package TimeWarp.State -Version 12.0.0-beta.17
                    
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="TimeWarp.State" Version="12.0.0-beta.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeWarp.State" Version="12.0.0-beta.17" />
                    
Directory.Packages.props
<PackageReference Include="TimeWarp.State" />
                    
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 TimeWarp.State --version 12.0.0-beta.17
                    
#r "nuget: TimeWarp.State, 12.0.0-beta.17"
                    
#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 TimeWarp.State@12.0.0-beta.17
                    
#: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=TimeWarp.State&version=12.0.0-beta.17&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=TimeWarp.State&version=12.0.0-beta.17&prerelease
                    
Install as a Cake Tool

Stars workflow Forks License Issues Open OpenSSF Scorecard

nuget nuget

Twitter Dotnet

Discord Twitter Twitter

<img src="https://raw.githubusercontent.com/TimeWarpEngineering/timewarpengineering.github.io/refs/heads/master/images/LogoNoMarginNoShadow.svg" alt="logo" height="120" style="float: right" />

TimeWarp.State

TimeWarp.State (previously known as Blazor-State) is a fully asynchronous state management library. The core package has no Blazor dependency, so console and other non-UI hosts can dispatch actions through the same store. Blazor components, JavaScript interop, and render subscriptions are in TimeWarp.State.Blazor. It handles both Reducers and Effects consistently using async Handlers.

By utilizing the TimeWarp.Mediator pipeline, TimeWarp.State enables a flexible, middleware-driven architecture for managing state, similar to the request-processing pipeline in ASP.NET. This approach allows developers to inject custom behaviors, such as logging, validation, and caching, directly into the state management flow.

Hosts consume TimeWarp.Mediator 15.0.0-beta.5 (TimeWarp.Mediator and, on the host, TimeWarp.Mediator.Generators) via generated AddGeneratedMediator<ClientPipeline>() / named pipelines — not MediatR and not reflection AddMediator(). Import TimeWarp.Mediator.Generated (or TimeWarpMediatorNamespace); the extension is internal there, and implicit usings do not include it.

In addition to the core library, we offer TimeWarp.State.Blazor (components, JavaScript interop, render subscriptions), TimeWarp.State.Plus (routing, persistence, action tracking; depends on TimeWarp.State.Blazor; package id unchanged), and TimeWarp.State.Telemetry (OpenTelemetry action spans for the Aspire dashboard or any OTel backend). TimeWarp DevTools is a dev-only Blazor inspector (AddTimeWarpStateDevTools()) on top of those spans. It is the action log, state tree, and diff. It is not a production dependency. The console sample dispatches an action without Blazor. The persistence sample shows session storage and local storage with [PersistentState]. The render control sample shows ShouldRender, parameter checks, and RegisterRenderTrigger. The telemetry sample wires the DevTools app into Aspire, including the WebAssembly counter.

Give a Star! ⭐

If you find this project useful, please give it a star. Thanks!

Getting Started

I recommend the state and action handler sample for a step-by-step guide to building a Blazor app with TimeWarp.State. The published docs are at timewarpengineering.github.io/timewarp-state.

See full documentation.

<img src="https://raw.githubusercontent.com/TimeWarpEngineering/timewarp-state/refs/heads/master/documentation/images/time-warp-state-one-way-flow.drawio.svg" alt="logo" height="400" style="" />

Installation

dotnet add package TimeWarp.State
dotnet add package TimeWarp.State.Blazor
dotnet add package TimeWarp.State.Plus
dotnet add package TimeWarp.State.Telemetry

Blazor hosts call AddTimeWarpState and AddTimeWarpStateBlazor. Console hosts call AddTimeWarpState only. See Migrate to 12.0.0-beta.10.

Check out the latest NuGet packages on the TimeWarp Enterprises NuGet page.

Writing an action

An action lives in a nested *ActionSet inside the state it changes. The recommended shape marks the Action with [Reducer] and declares one static Reduce method. The source generator writes the handler:

public sealed partial class CounterState : State<CounterState>
{
  public int Count { get; private set; }

  public override void Initialize() => Count = 0;

  public static partial class IncrementCountActionSet
  {
    [Reducer]
    public sealed class Action(int amount) : IAction
    {
      public int Amount { get; } = amount;
    }

    private static void Reduce(CounterState state, Action action) => state.Count += action.Amount;
  }
}

await CounterState.IncrementCount(amount: 5); // generated dispatch method

Write the Handler : StateActionHandler<Action> yourself instead when the action does async work, needs injected services, or does more than change the state synchronously. That long shape keeps working, and one state can mix both. See Actions.

JavaScript dispatch

JavaScript can dispatch actions with timeWarpState.DispatchRequest(name, request). It is opt-in: allow each action explicitly, everything else is rejected.

builder.Services.AddJavaScriptDispatch(b => b.Allow<CounterState.IncrementCountActionSet.Action>());

See Enable JavaScript interop.

Action catalog

Mark user-facing actions with [CatalogAction] to enumerate and execute them at runtime, for example from a Ctrl-K command palette or as agent tools:

public static class AddPasskeyActionSet
{
  [CatalogAction(Description = "Add a passkey to the signed-in account.", Permissions = ["credentials.write"])]
  public sealed class Action : IAction
  {
    public Action(string label) { Label = label; }
    public string Label { get; }
  }
}
builder.Services.AddActionCatalog(typeof(AssemblyMarker).Assembly);

ActionCatalogEntry entry = actionCatalog.Find("Credentials.AddPasskey")!;
await entry.Execute(store, ["Laptop"]);

The source generator emits a per-assembly registry with name, description, permissions, visibility, parameters and input schema, plus a reflection-free Execute. It is opt-in: unmarked actions are never cataloged. Permissions are opaque ids that the consumer enforces; [TrackAction] (busy indicator) is unrelated. See Action catalog.

Releases

View the Release Notes for detailed information on each release.

Unlicense

License
This project is licensed under the Unlicense.

Contributing

Your contributions are welcome! Before starting any work, please open a discussion.

Help with the documentation is also greatly appreciated.

Contact

If you have an issue and don't receive a timely response, feel free to reach out on our Discord server.

Discord

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on TimeWarp.State:

Package Downloads
TimeWarp.State.Plus

TimeWarp.State.Plus extends TimeWarp.State and TimeWarp.State.Blazor with routing, persistence, and action tracking.

TimeWarp.State.Policies

Policies for TimeWarp State management library

TimeWarp.State.Telemetry

OpenTelemetry instrumentation for the TimeWarp.State mediator pipeline: action spans, timing, and opt-in AOT-safe state snapshots.

TimeWarp.State.Blazor

Blazor components, JavaScript interop, and render subscriptions for TimeWarp.State.

TimeWarp.State.DevTools.Export

Dev-only exporter that copies TimeWarp.State activity spans to the DevTools inspector. Not a production dependency.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
12.0.0-beta.17 106 11/6/2026
12.0.0-beta.16 191 10/31/2026
12.0.0-beta.15 350 10/16/2026
12.0.0-beta.14 88 10/16/2026
12.0.0-beta.13 226 10/13/2026
12.0.0-beta.12 78 10/12/2026
12.0.0-beta.11 79 10/12/2026
12.0.0-beta.10 191 10/9/2026
12.0.0-beta.9 126 10/9/2026
12.0.0-beta.8 181 10/5/2026
12.0.0-beta.7 104 10/1/2026
12.0.0-beta.6 114 9/30/2026
12.0.0-beta.5 85 9/24/2026
12.0.0-beta.3 209 9/17/2026
12.0.0-beta.1 2,436 8/20/2025
11.0.3 19,748 6/20/2025
11.0.2 291 6/20/2025
11.0.1 264 6/20/2025
11.0.0 4,310 12/10/2024
11.0.0-beta.96 137 12/5/2024
Loading failed