Getting Started
Get up and running with EasyAppDev.Blazor.Store in less than 5 minutes. This guide walks you through installation, basic setup, and your first component.
Installation
Add the package to your Blazor project using the .NET CLI:
dotnet add package EasyAppDev.Blazor.Store
Requirements
- .NET 8.0 or higher
- Blazor Server, WebAssembly, or Blazor Web App
- Package size: Only 38 KB gzipped (less than 0.1% of your app)
See Render Modes compatibility notes for information about DevTools and LocalStorage features in different render modes.
Quick Start
Follow these three simple steps to add state management to your Blazor application:
Define Your State
State is just a C# record with transformation methods. No actions, no reducers, no dispatch.
public record CounterState(int Count)
{
public CounterState Increment() => this with { Count = Count + 1 };
public CounterState Decrement() => this with { Count = Count - 1 };
public CounterState Reset() => this with { Count = 0 };
}
State methods use the with expression to create new state instances. This ensures immutability and predictable updates.
Register in Program.cs
Register your store with all features enabled using a single line:
// One-liner registration with all features
builder.Services.AddStoreWithUtilities(
new CounterState(0),
(store, sp) => store.WithDefaults(sp, "Counter"));
AddStoreWithUtilities()- Includes async helpers (debounce, throttle, cache, etc.)WithDefaults()- Adds Redux DevTools, logging, and JSRuntime integration
Use in Components
Inherit from StoreComponent<TState> to get automatic reactivity:
@page "/counter"
@inherits StoreComponent<CounterState>
<h1>@State.Count</h1>
<button @onclick="@(() => UpdateAsync(s => s.Increment()))">+</button>
<button @onclick="@(() => UpdateAsync(s => s.Decrement()))">-</button>
<button @onclick="@(() => UpdateAsync(s => s.Reset()))">Reset</button>
No actions, no reducers, no dispatch. Inherit from StoreComponent<T> and call UpdateAsync(). The component automatically re-renders when state changes.
What You Get Out of the Box
Automatic Reactivity
Components inherit from StoreComponent<T> and automatically update when state changes.
Immutability
C# records with with expressions ensure state is never mutated directly.
Redux DevTools
Time-travel debugging and state inspection with the Redux DevTools browser extension.
Async Helpers
Built-in utilities like UpdateDebounced, AsyncData<T>, and ExecuteAsync reduce boilerplate by 74%.
Persistence
Auto-save and restore state from LocalStorage or SessionStorage.
100% Testable
State methods are pure functions - easy to unit test without mocks.
Next Steps
Now that you have a basic setup, explore these topics to get the most out of the library:
Need Help?
- API Reference: Complete API documentation
- GitHub: Source code and issue tracker
- NuGet: Package downloads and versions