If passing data between your Blazor components is too painful...

Published on

In a previous article I wrote about a few options for passing state between Blazor components.

In truth those options will serve you well for many, many Blazor applications, but if you’re finding it painful to pass state between components using parameters, callbacks and binding, you might need something else.

Once you have multiple components at different levels in your application, passing state around between them can quickly spiral into a bit of a maintenance nightmare.

An alternative is to employ centralised state management with a library like Fluxor, or Blazor-State.

With both of these libraries you create a ‘Store’ for your application, wire your components up to that store and then they’re able to react as that state changes.

NOTE

No such thing as a free lunch

It’s worth pointing out before you continue that nothing is free, especially in software development and adopting something like Blazor-State or Fluxor does cost (in terms of time to learn, implement and ultimately maintain the application) but if the other options don’t cut it, it might be worth a look.

For the rest of this article we’ll focus on Blazor-State.

I know you don't have endless hours to learn ASP.NET

Cut through the noise, simplify your web apps, ship your features. One high value email every week.

I respect your email privacy. Unsubscribe with one click.

    Next Up
    1. Is it possible to render components dynamically using Blazor?
    2. Render Blazor WASM components in your existing MVC/Razor Pages applications
    3. Prerendering your Blazor WASM application with .NET 5 (part 2 - solving the missing HttpClient problem)