You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# EasyAppDev.Blazor.Store - Blazor State Management Library
2
2
3
-
**Type-safe state management for Blazorusing C# records.**
3
+
**Zustand-inspired state management for Blazor** - Type-safe, immutable, zero-boilerplate state management using C# records. The simplest way to manage state in Blazor Server, WebAssembly, and Auto modes.
4
4
5
-
*Inspired by Zustand • Built for C# developers*
5
+
*Built for C# developers who want Redux-like power without the complexity*
|**Immutable State**| C# records with `with` expressions for predictable state updates |
36
+
|**Zero Boilerplate**| No actions, reducers, or dispatchers required |
37
+
|**Redux DevTools**| Time-travel debugging with full state inspection |
38
+
|**Persistence**| Automatic LocalStorage/SessionStorage state saving |
39
+
|**Cross-Tab Sync**| Real-time state synchronization across browser tabs |
40
+
|**Server Sync**| SignalR-based real-time collaboration with presence |
41
+
|**Undo/Redo**| Full history stack with memory management |
42
+
|**Type-Safe**| Complete IntelliSense and compile-time checking |
43
+
|**Async Support**| Built-in debounce, throttle, and lazy loading |
44
+
|**Optimistic Updates**| Instant UI feedback with automatic rollback |
45
+
46
+
---
47
+
48
+
## What is State Management in Blazor?
32
49
33
50
In Blazor applications, "state" is any data your app needs to remember—user input, fetched data, UI flags like "is loading" or "is sidebar open." Without a state management library, you end up passing data through component parameters, juggling `EventCallback` chains, or scattering state across services. This quickly becomes hard to track and debug. A state management library gives you a single source of truth: one place where state lives, one way to update it, and automatic notifications to any component that cares. Think of it as a central database for your UI that keeps everything in sync.
34
51
35
52
---
36
53
37
-
## Why This Library?
54
+
## Why Choose This Blazor State Management Library?
38
55
39
56
No actions. No reducers. No dispatchers. Just C# records with pure methods.
40
57
41
58
```csharp
42
-
// Define state as a record with transformation methods
59
+
// Define Blazor state as an immutable C# record
43
60
publicrecordCounterState(intCount)
44
61
{
62
+
// Pure state transformation - returns new immutable state
-**Choose EasyAppDev.Blazor.Store** if you want minimal boilerplate, built-in features (persistence, sync, undo/redo), and a Zustand-like developer experience
1211
+
-**Choose Fluxor** if your team is familiar with Redux/Flux patterns and needs strict unidirectional data flow
1212
+
-**Choose Blazor-State** if you prefer MediatR-style request/handler patterns
1213
+
1214
+
---
1215
+
1216
+
## Frequently Asked Questions (FAQ)
1217
+
1218
+
### How does this compare to Fluxor?
1219
+
1220
+
Fluxor follows traditional Redux patterns with actions, reducers, and effects. EasyAppDev.Blazor.Store takes a simpler approach inspired by Zustand - your state is just a C# record with methods. No boilerplate, no ceremony. Both support Redux DevTools.
1221
+
1222
+
### Can I use this with Blazor Server?
1223
+
1224
+
Yes. Use `AddScopedStore` for full feature support (DevTools, persistence, cross-tab sync) in Blazor Server. Singleton stores work but cannot use JavaScript-dependent features.
1225
+
1226
+
### How do I persist state to localStorage?
1227
+
1228
+
```csharp
1229
+
builder.Services.AddStoreWithUtilities(
1230
+
newAppState(),
1231
+
(store, sp) =>store
1232
+
.WithDefaults(sp, "App")
1233
+
.WithPersistence(sp, "app-state")); // Auto-saves to localStorage
1234
+
```
1235
+
1236
+
### Does this work with .NET MAUI Blazor?
1237
+
1238
+
Yes. The core store functionality works in MAUI Blazor Hybrid apps. Browser-specific features (DevTools, localStorage, cross-tab sync) require a browser context.
1239
+
1240
+
### How do I handle async operations like API calls?
1241
+
1242
+
Use the built-in `ExecuteAsync` helper or async state methods:
Install the [Redux DevTools browser extension](https://github.com/reduxjs/redux-devtools). State changes are automatically logged in DEBUG builds when using `WithDefaults()` or `WithDevTools()`.
1263
+
1264
+
### Can multiple components share the same state?
1265
+
1266
+
Yes. All components inheriting `StoreComponent<T>` for the same state type automatically share state and receive updates.
1267
+
1268
+
---
1269
+
1172
1270
## Common Gotchas
1173
1271
1174
1272
1.**Always use `with`**: `state with { X = 1 }` not `state.X = 1`
If EasyAppDev.Blazor.Store has made state management easier in your Blazor projects, consider giving it a ⭐ on GitHub. It helps others discover the library and motivates continued development.
0 commit comments