Minimact.AspNetCore 0.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Minimact.AspNetCore --version 0.1.4
                    
NuGet\Install-Package Minimact.AspNetCore -Version 0.1.4
                    
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="Minimact.AspNetCore" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Minimact.AspNetCore" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Minimact.AspNetCore" />
                    
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 Minimact.AspNetCore --version 0.1.4
                    
#r "nuget: Minimact.AspNetCore, 0.1.4"
                    
#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 Minimact.AspNetCore@0.1.4
                    
#: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=Minimact.AspNetCore&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Minimact.AspNetCore&version=0.1.4
                    
Install as a Cake Tool

Minimact C# Runtime

ASP.NET Core runtime for the Minimact framework - a server-side React-like framework with Rust-powered reconciliation.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                     Minimact Runtime                         │
│                                                             │
│  ┌──────────────────┐  ┌──────────────────┐               │
│  │ MinimactComponent │  │  ComponentRegistry│               │
│  │   (Base Class)   │  │   (Singleton)    │               │
│  └────────┬─────────┘  └──────────────────┘               │
│           │                                                 │
│  ┌────────▼─────────┐  ┌──────────────────┐               │
│  │  StateManager    │  │   RustBridge     │               │
│  │  ([State] attrs) │  │   (FFI to Rust)  │               │
│  └──────────────────┘  └────────┬─────────┘               │
│                                  │                          │
│  ┌──────────────────┐  ┌────────▼─────────┐               │
│  │   MinimactHub     │  │  minimact.dll     │               │
│  │   (SignalR)      │  │  (Rust Engine)   │               │
│  └──────────────────┘  └──────────────────┘               │
└─────────────────────────────────────────────────────────────┘

Project Structure

Minimact.AspNetCore/
├── Core/
│   ├── VNode.cs                  # Virtual DOM types
│   ├── MinimactComponent.cs       # Base component class
│   ├── StateAttribute.cs         # [State] attribute
│   ├── StateManager.cs           # State synchronization
│   ├── RustBridge.cs             # FFI to Rust engine
│   └── ComponentRegistry.cs      # Component instance registry
├── SignalR/
│   └── MinimactHub.cs             # SignalR hub for real-time updates
├── Extensions/
│   └── MinimactServiceExtensions.cs  # ASP.NET Core integration
└── Examples/
    ├── Counter.cs                # Simple counter example
    └── TodoList.cs               # Todo list with state management

Key Components

VNode Types (VNode.cs)

Virtual DOM representation matching Rust implementation:

  • VNode - Abstract base class
  • VElement - HTML elements (<div>, <button>, etc.)
  • VText - Text nodes with HTML encoding
  • DivRawHtml - Raw HTML for markdown rendering
  • Fragment - React.Fragment-like wrapper
var node = new VElement("div", new VNode[]
{
    new VElement("h1", "Hello World"),
    new VText("Some text content")
});

string html = node.ToHtml();
// Output: <div><h1>Hello World</h1>Some text content</div>

MinimactComponent (MinimactComponent.cs)

Base class for all components with:

  • State management via SetState() and GetState()
  • Lifecycle hooks (OnInitializedAsync, OnStateChanged, etc.)
  • Rendering via abstract Render() method
  • SignalR integration for real-time patches
public class MyComponent : MinimactComponent
{
    [State]
    private int count = 0;

    protected override VNode Render()
    {
        return new VElement("div", $"Count: {count}");
    }

    private void Increment()
    {
        count++;
        SetState(nameof(count), count);
    }
}

StateManager (StateManager.cs)

Syncs [State] decorated fields/properties with internal state dictionary using reflection:

  • InitializeState() - Read initial values from fields
  • SyncStateToMembers() - Update fields after state changes
  • SyncMembersToState() - Capture field changes before render

RustBridge (RustBridge.cs)

P/Invoke wrapper for Rust reconciliation engine:

// Compute patches
var patches = RustBridge.Reconcile(oldVNode, newVNode);

// Predictor for learning patterns
using var predictor = new RustBridge.Predictor();
predictor.Learn(stateChange, oldTree, newTree);
var prediction = predictor.Predict(stateChange, currentTree);

MinimactHub (MinimactHub.cs)

SignalR hub for client communication:

  • RegisterComponent() - Connect component to client
  • InvokeComponentMethod() - Handle client events (clicks, etc.)
  • UpdateClientState() - Sync useClientState values
  • Auto-cleanup on disconnect

ComponentRegistry (ComponentRegistry.cs)

Thread-safe singleton registry:

registry.RegisterComponent(component);
var component = registry.GetComponent(componentId);
registry.UnregisterComponent(componentId);

Usage

1. Add to ASP.NET Core app

// Program.cs
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddMinimact(options =>
{
    options.EnablePrediction = true;
    options.EnableDebugLogging = false;
});

var app = builder.Build();
app.UseMinimact();
app.Run();

2. Create a component

public class Counter : MinimactComponent
{
    [State]
    private int count = 0;

    public override Task OnInitializedAsync()
    {
        StateManager.InitializeState(this);
        return Task.CompletedTask;
    }

    protected override VNode Render()
    {
        StateManager.SyncMembersToState(this);

        return new VElement("div", new VNode[]
        {
            new VElement("h1", $"Count: {count}"),
            new VElement("button", new Dictionary<string, string>
            {
                ["onclick"] = nameof(Increment)
            }, "Increment")
        });
    }

    private void Increment()
    {
        count++;
        SetState(nameof(count), count);
    }
}

3. Render component in controller

public class HomeController : Controller
{
    private readonly ComponentRegistry _registry;

    public HomeController(ComponentRegistry registry)
    {
        _registry = registry;
    }

    public async Task<IActionResult> Index()
    {
        var counter = new Counter();
        _registry.RegisterComponent(counter);

        var html = (await counter.InitializeAndRenderAsync()).ToHtml();
        ViewBag.ComponentId = counter.ComponentId;
        ViewBag.Html = html;

        return View();
    }
}

Features

Virtual DOM - React-like VNode tree structure ✅ State Management - [State] attributes with auto-sync ✅ Rust Reconciliation - High-performance diffing via FFI ✅ SignalR Patches - Real-time DOM updates ✅ Predictive Rendering - ML-based patch prediction ✅ Lifecycle Hooks - Initialize, state changes, mount/unmount ✅ Component Registry - Global instance management ✅ Type Safety - Full C# type checking

Next Steps

  1. Build Rust library - Compile minimact.dll from Rust source
  2. Client runtime - Create minimact.js for DOM patching
  3. Babel integration - Connect TSX transformer to C# codegen
  4. Hybrid rendering - Implement useClientState zones
  5. Testing - Unit tests for all components

Examples

See Examples/ folder:

  • Counter.cs - Basic state and event handling
  • TodoList.cs - List rendering with keyed reconciliation

Dependencies

  • .NET 8.0
  • Microsoft.AspNetCore.SignalR.Core 1.1.0
  • Markdig 0.37.0 (for useMarkdown)
  • Newtonsoft.Json 13.0.3 (for JSON serialization)
  • minimact.dll (Rust reconciliation engine)

License

MIT

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 (2)

Showing the top 2 NuGet packages that depend on Minimact.AspNetCore:

Package Downloads
Minimact.Charts

Server-side charting library for Minimact with zero client bundle overhead. Includes Bar, Line, Pie, and Area charts with Recharts-inspired API.

Minimact.Powered

Interactive "Powered by Minimact" badge plugin with smooth slide-out animation. Uses parameterized template patches for instant state transitions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.6 273 11/10/2025
0.1.5 254 11/10/2025
0.1.4 196 11/3/2025
0.1.3 149 11/1/2025
0.1.2 183 10/29/2025
0.1.1 178 10/29/2025
0.1.0 178 10/29/2025