SimpleFlux.NET 3.0.0

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

SimpleFluxDotNet

A simple Flux architecture implementation for .NET applications with minimal dependencies and boilerplate code. Particularly useful for Blazor applications.

NuGet License: MIT

Features

  • ðŸŠķ Lightweight Flux implementation
  • ⚡ First-class Blazor support
  • ðŸ“Ķ Minimal dependencies
  • 🔒 Type-safe state management
  • 💉 Easy integration with dependency injection
  • 🔌 Built-in middleware support

Installation

Install via NuGet:

dotnet add package SimpleFlux.NET

Quick Start

  1. Define your state:
public sealed record ExampleState : AbstractFluxState
{
    public int Counter { get; init; }
    public WeatherForecast[]? Forecasts { get; init; }
}
  1. Create actions:
public sealed record IncrementCounterButtonClickedAction : IFluxAction { }
  1. Create a reducer:
public sealed class IncrementCounterReducer : IFluxReducer<ExampleState, IncrementCounterButtonClickedAction>
{
    public ExampleState Reduce(IncrementCounterButtonClickedAction action, ExampleState currentState) => currentState with
    {
        Counter = currentState.Counter + 1
    };
}
  1. Set up in your Blazor application:
builder.Services.AddFluxStateManagement(flux =>
{
    flux.ConfigureStateContainer<ExampleState>(state =>
    {
        state.HandleAction<IncrementCounterButtonClickedAction>(action => 
            action.UseReducer<IncrementCounterReducer>());
        
        // You can also define inline reducers
        state.HandleAction<SomeOtherAction>(action =>
        {
            action.UseReducer(static (action, state) => state with
            {
                // Update state here
            });
        });
        
        // Or use middleware for side effects
        state.HandleAction<LoadDataAction>(action => 
            action.UseMiddleware<LoadDataMiddleware>());
    });
});
  1. Use in components:
@page "/counter"
@using SimpleFluxDotNet.Abstractions
@inherits FluxComponent<ExampleState>

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @State.Current.Counter</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    private Task IncrementCount() =>
        State.DispatchAsync(new IncrementCounterButtonClickedAction());
}

Project Structure

  • SimpleFluxDotNet - Core library with Flux implementation
  • SimpleFluxDotNet.Example - Example Blazor application showcasing usage
  • SimpleFluxDotNet.Tests - Unit tests

Documentation

Core Concepts

  • State: Immutable state container that holds your application's data
  • Actions: Plain objects describing what happened
  • Reducers: Pure functions that specify how the state changes in response to actions
  • Store: Holds the state and handles dispatching of actions
  • Middleware: Intercepts actions for side effects, logging, etc.

Components

IFluxAction

The base interface for all actions in your application.

AbstractFluxState

Base class for your application's state objects.

FluxComponent

Base component class that provides access to state and dispatch capabilities.

IFluxReducer<TState, TAction>

Interface for implementing reducers that handle specific action types. Reducers are pure functions that take the current state and an action, and return a new state.

public interface IFluxReducer<TState, TAction> where TState : AbstractFluxState where TAction : IFluxAction
{
    TState Reduce(TAction action, TState currentState);
}
IFluxMiddleware<TState, TAction>

Interface for implementing middleware that handles side effects for specific action types. Middleware can perform async operations and dispatch additional actions.

public interface IFluxMiddleware<TState, TAction> where TState : AbstractFluxState where TAction : IFluxAction
{
    Task HandleAsync(TAction action, TState currentState, IFluxDispatcher dispatcher);
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

cjbush

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
3.0.0 474 10/4/2025
3.0.0-preview006 206 9/26/2025
3.0.0-preview003 236 9/22/2025
3.0.0-preview001 241 9/21/2025
2.6.1 377 9/16/2025
2.6.0 326 9/16/2025
2.5.1 461 3/5/2024
2.5.0 209 2/26/2024
2.4.0 168 2/26/2024