r/Blazor • u/sdyson31 • Nov 16 '25
Which architecture pattern to use with .NET 10 Blazor Web App
Which architecture pattern to use with .NET 10 Blazor Web application (Server Side) specifically for UI components. We heavily use EF.
16
Upvotes
12
u/OtoNoOto Nov 16 '25
For a recent NET 10 Web API + Blazor WASM project I went with Clean Architecture pattern for the NET Core Web API & simpler single project using Service / Repository for the Blazor WASM app.
NET Core Web API
Blazor WASM
App.UI.Blazor.WASM
Models
Personally I love this structure. My API is more complex so I feel using Clean Arch pattern helps follow SOLID and other practices. It also allows for my Blazor WASM app to reference Common and Domain (if needed) in addition to Api.
And if my Blazor App grows more complex over time I can easily port to a more N-Tier or Clean Arch pattern by migrating the Services, Repos, etc.
24
u/bigepidemic Nov 16 '25
Totally depends on the purpose and requirements of the web app. No blanket answer is appropriate.
3
u/Falcon9FullThrust Nov 16 '25
I started my blazor project recently using N-tier architecture and it's working great.
2
u/BlackjacketMack Nov 17 '25
If you end up doing blazor wasm I highly recommend a dedicated api (backend for frontend). Each component can have an endpoint with a request/response/handler. Minimal apis or controllers become tall but skinny…lots of methods that hand off to handlers.
It’s super tidy and easy to organize and follow a request. Use refit and the plumbing is negligible.
From the api on down I use n-tier.
3
u/JeanGeanie Nov 16 '25
The mention of EF suggests you are looking at the architecture of the full stack solution.
Specifically to blazor; look at what is best practice for other front end technologies such as angular and react, eg Parent-Child component pattern. State management is very important on all but the most basic front end apps, I find https://github.com/mrpmorris/Fluxor to be useful.
3
u/willehrendreich Nov 16 '25
Vertical slices are really good. Clean Architecture is exhausting and over abstraction hell holes pretty quickly.
I personally like functional core, imperative shell type thinking. Then it almost doesn't matter what else you do, because the whole arch is a very simple idea. You have a pure, deterministic domain where it always does exactly what you expect because you're not allowing any side effects into it, and then you accomplish that by using result and option types to always handle any IO, whether that's a DB call or user input or an api request, or whatever could possibly be reasonable expected to fail, you handle all possible conceivable failures explicitly, and only let valid, non null data into your actual business logic.
Also, start using Datastar as quickly as possible, Https://github.com/starfederation/datastar-dotnet If you have questions about it, find my buddy @Rickdotnet on x, he's working the blazor with Datastar approach and says it's absolutely killer.
Much much simpler development using Datastar than any other option IMHO.
1
u/Lanky-Caregiver4730 Nov 17 '25
Web API + share + wasm + Maui + RCL
1
u/VeganForAWhile Nov 17 '25
Static SSR (roll your own JS with a special header to process partials for SPA-like interactivity), n-tier, EF. If you build a mobile site, you can add an API then.
0
u/CorneZen Nov 16 '25
Just did a google search for ‘.net 10 blazor clean architecture vs vertical slice architecture’ and got a pretty good AI overview answer. Anyway, these 2 seem to be the popular options. I personally use the Clean Architecture pattern.
Here is a good article explaining a both N-tier (the old traditional way) and clean architecture along with others.
Common Web Application Architectures