What are the common strategies for managing state in a large Blazor app, comparing component-local state, cascading values, and app-state services?
Last updated
Hold state at the narrowest scope: component-local fields for UI-only concerns,
CascadingValuefor context shared within a subtree (theme, auth).Use DI app-state services (
AddScoped/AddSingletonwith change events) for cross-page state. They need manual subscribe/unsubscribe and care with lifetimes (server vs WASM).For very large apps, consider a Flux/Redux library like
Fluxor, and back state with browser storage or the server for persistence across reloads.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/state-management/?view=aspnetcore-10.0
- https://www.syncfusion.com/blogs/post/master-state-management-in-blazor
- https://medium.com/dotnet-new/state-management-in-blazor-applications-0890c20ca3b2
- https://learn.microsoft.com/es-es/aspnet/core/blazor/state-management/?view=aspnetcore-12.0
- https://learn.microsoft.com/ca-es/aspnet/core/blazor/state-management/webassembly?view=aspnetcore-12.0
- https://medium.com/dotnet-new/state-management-in-blazor-beyond-cascading-parameters-b4bed4b5bbf5
- https://medium.com/@robhutton8
- https://www.luisllamas.es/en/blazor-state-management-in-memory-container/