Options for State Management in Blazor

12.1k views Asked by At

What libraries/techniques are available in Blazor for State management for webassembly (wasm).

It would be nice to know pros and cons of different approaches.

2

There are 2 answers

0
Neil On

There are several options:

Redux (Fluxor)

Redux/Flux pattern has become a leader in state management in JS word; so it would make sense to adopt this best practice.

Luckily there is already a Fluxor library that does just that; and it does have the most github stars 379; although it is still a relatively new area; so it remains to be seen what ends up being the most adopted approach later on.

There is a great intro video along with source code

Official docs:

  • State, actions, and reducers
  • Effects
  • Redux Dev Tools

An in depth article.

Blazor-State

Blazor-State

Pros: uses MediatR for messaging

See also

Overviews of State Management Approaches

https://chrissainty.com/mobile-blazor-bindings-state-management-and-data/

https://jonhilton.net/blazor-state-management/

https://learn.microsoft.com/en-us/aspnet/core/blazor/state-management

nice but mostly messaging: https://jasonwatmore.com/post/2020/07/30/aspnet-core-blazor-webassembly-communication-between-components

keywords: passing data between blazor wasm webassembly components child parent attributes events handling

7
Dean Chalk On

A Blazor app is a C# app on top of the .Net BCL libraries. We don’t need to emulate what the JavaScript world has created to overcome its own deficiencies. C# can cache anything you want with static members.