Blazing.Mvvm
Blazor + CommunityToolkit.Mvvm
Bring full MVVM patterns to Blazor without hand-written glue code.
Blazing.Mvvm adds ViewModel-aware components, strongly typed navigation, parameter resolution, validation support, and sample apps across Server, WebAssembly, Web App, and Hybrid hosts.
Quick Start
Install the package
dotnet add package Blazing.MvvmRegister Blazing.Mvvm in
Program.csbuilder.Services.AddMvvm(options => { options.HostingModelType = BlazorHostingModelType.WebApp; });Create a ViewModel
public partial class CounterViewModel : ViewModelBase { [ObservableProperty] private int _count; [RelayCommand] private void Increment() => Count++; }Use it in a component
@page "/counter" @inherits MvvmComponentBase<CounterViewModel> <p role="status">Current count: @ViewModel.Count</p> <button class="btn btn-primary" @onclick="ViewModel.IncrementCommand.Execute"> Click me </button>
For the full walkthrough, including configuration options, ViewModel setup, and component usage, see the Getting Started guide.
Highlights
ViewModel components
Inherit MvvmComponentBase for most pages and components. Use MvvmOwningComponentBase when the view needs its own DI scope for a DbContext or repository, or MvvmLayoutComponentBase for layouts. Lifecycle calls such as OnInitializedAsync run on the ViewModel.
Typed navigation
Call NavigateTo<TViewModel>() and the route is resolved from the type, an interface, or a key. Rename a @page and your call sites still compile.
Parameters and binding
Mark a property [ViewParameter] to receive the matching component [Parameter]. Components that follow the @bind- convention get two-way binding, cleaned up on dispose.
Validation
MvvmObservableValidator plugs an ObservableValidator model into an EditForm, so [Required] and [EmailAddress] validate the usual way.
Messaging
RecipientViewModelBase wraps ObservableRecipient, so ViewModels send and receive IMessenger messages for parent-child and cross-page updates.
Runs on every host
The same ViewModels run on Blazor Server, WebAssembly, Web App, and Hybrid (WPF, WinForms, MAUI, Avalonia). Subpath and YARP base paths are read from the request, so reverse-proxy setups need no extra configuration.
Analyzers and fixes
Roslyn analyzers flag the wrong base class, an unsafe navigation target, or a broken dispose, and ship with one-click code fixes.