ZeroAlloc.Flux 2.0.1

dotnet add package ZeroAlloc.Flux --version 2.0.1
                    
NuGet\Install-Package ZeroAlloc.Flux -Version 2.0.1
                    
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="ZeroAlloc.Flux" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroAlloc.Flux" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ZeroAlloc.Flux" />
                    
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 ZeroAlloc.Flux --version 2.0.1
                    
#r "nuget: ZeroAlloc.Flux, 2.0.1"
                    
#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 ZeroAlloc.Flux@2.0.1
                    
#: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=ZeroAlloc.Flux&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ZeroAlloc.Flux&version=2.0.1
                    
Install as a Cake Tool

ZeroAlloc.Flux

NuGet Build codecov License: MIT AOT GitHub Sponsors

Source-generated Flux/Redux state management for .NET and Blazor, an alternative to Fluxor: no reflection, no allocations when you dispatch, NativeAOT-ready.

Why ZeroAlloc.Flux

  • 0 B per dispatch. Dispatching an action, fanning it out to several features, notifying subscribers and reading the state allocate nothing; tests assert each path on net10.0 and net11.0, including dispatch to a store that a Blazor FluxComponent subscribes to.
  • Dispatch is generated code. The dispatcher is built at compile time from your [Reducer] methods and resolves to a direct call per action type: no handler dictionary, no reflection.
  • Works under NativeAOT and trimming. CI publishes and runs a NativeAOT app, and builds a Blazor WebAssembly app, on every build.
  • Compile-time diagnostics. A wrong reducer signature, a duplicate reducer or a feature that is not partial stops the build with a ZFLUX error instead of failing at runtime.

Install

dotnet add package ZeroAlloc.Flux

The source generator ships inside the package. A console app also needs a DI container, for example dotnet add package Microsoft.Extensions.DependencyInjection; ASP.NET Core and Blazor already have one.

Quick start

using Microsoft.Extensions.DependencyInjection;
using ZeroAlloc.Flux;
using ZeroAlloc.Flux.Generated;

using var sp = new ServiceCollection().AddZeroAllocFlux().BuildServiceProvider();
var dispatcher = sp.GetRequiredService<IDispatcher>();
var counter = sp.GetRequiredService<IStore<CounterState>>();

counter.StateChanged += state => Console.WriteLine($"Count is now {state.Count}");

await dispatcher.DispatchAsync(new Increment(5));  // Count is now 5
await dispatcher.DispatchAsync(new Increment(3));  // Count is now 8

[Feature]
public readonly partial record struct CounterState(int Count);

public readonly record struct Increment(int Amount);

public static class CounterReducers
{
    [Reducer]
    public static CounterState On(CounterState state, Increment action)
        => state with { Count = state.Count + action.Amount };
}

State is a record, actions are plain types with no marker interface, and reducers are static methods. The generator writes the store, the dispatcher and AddZeroAllocFlux.

What you get

  • Stores per state slice, safe for concurrent dispatch and reads, with a StateChanged event. Core concepts
  • One action, many features: every reducer for an action runs, as in Redux and Fluxor.
  • Custom initial state through a factory that can use your services. Initial state
  • Effects as plain services that inject IDispatcher, do async work and dispatch the result. Effects
  • Blazor support: ZeroAlloc.Flux.Blazor adds FluxComponent, which re-renders when a store it subscribes to changes. Blazor guide
  • Build-time checks, ZFLUX001 to ZFLUX009. Diagnostics
  • Targets net10.0 and net11.0.

Performance

Exact allocation budgets, each asserted by an AllocationGate test over 1,000 calls in CI:

Hot path Allocated
DispatchAsync to one record struct feature 0 B
DispatchAsync fanned out to two features, each raising StateChanged to a subscriber 0 B
IStore<TState>.Value read 0 B

The budgets hold for the library's own work; a record class feature allocates the new state your reducer returns. What still allocates, why dispatch does not, and how to run the benchmarks: docs/performance.md.

Learn more

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ZeroAlloc.Flux:

Package Downloads
ZeroAlloc.Flux.Blazor

Blazor host adapter for ZeroAlloc.Flux — FluxComponent base class and DI extensions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 63 11/22/2026
2.0.0 103 11/22/2026
1.4.1 196 11/16/2026
1.4.0 515 11/11/2026
1.3.0 613 10/28/2026
1.2.2 213 10/16/2026
1.2.1 134 10/16/2026
1.2.0 129 10/15/2026
1.1.11 1,111 10/12/2026
1.1.10 134 10/12/2026
1.1.9 130 10/11/2026
1.1.8 134 9/30/2026
1.1.7 142 9/30/2026
1.1.6 117 9/30/2026
1.1.5 136 9/28/2026
1.1.4 175 9/20/2026
1.1.3 132 9/20/2026
1.1.2 135 9/20/2026
1.1.1 165 9/14/2026
1.1.0 310 8/7/2026
Loading failed