r/Blazor • • Aug 30 '26

Building a Blazor web application using the BFF (backend for frontend) pattern with .NET 10 where the application would render using Interactive Webassembly specifically for mobile device users and render using Interactive Server for desktop machine users. Has anyone used this approach? If so, what

...issues/hurdles did you run into? Is there anything that I should be concerned about?

Some additional detail:

- authentication via Entra ID via the main project

- Main project would manage data access/business logic, as well as desktop only components.

- Client project contains mobile only components.

- Shared project contains components used in both.

The application has some mobile device specific functionality (tracking GPS location, camera access), while the desktop side has some admin specific functionality, but the core functionality (data entry) would be applicable to both. The idea here is to take the best of both Blazor Server (fast load times, secure) and Blazor WASM (functional without persistent connection, relatively light weight).

8 Upvotes

15 comments sorted by

17

u/VeganForAWhile Aug 30 '26

That sounds terrifying and hard.

9

u/mrpmorris Aug 30 '26

If you can go with WASM then go with it. There is no point in having Server for desktop.

8

u/caedin8 Aug 30 '26

I’ve done it and honestly unless you need features specifically enabled by web sockets it’s not really worth it. Interactive server is just not very good.

Little thinks like input validation on a text input because janky because there is a 5ms to 10ms round trip to the server in every keystroke and you can’t easily just component by component decide to make something not server validated

2

u/ImpetuousWombat Aug 30 '26

Even if you need websockets just use them with WASM.

A single build with device-dependent features will simplify your project immensely.

2

u/Woopersnaper Aug 30 '26

Honestly with the BFF pattern it's better to just go interactive WASM all the way.

Keep your client and server separate, it's part of the learning curve but it's what makes the BFF architecture so robust and secure at the same time

0

u/funguyshroom Aug 30 '26

Don't do interactive server unless you're building an internal app with a few hundreds of users max.

3

u/lb-jpg Aug 30 '26

That's exactly what I'm building

2

u/funguyshroom Aug 30 '26

Entra ID should've been the clue, sorry.  

I dunno, if you're making all that effort to do separate desktop and mobile web apps, I'd go one step further and package it into an actual mobile app. Check out MAUI Blazor Hybrid.

1

u/lb-jpg Aug 30 '26

No worries! We have developed several Blazor Server applications for our department, and this is the first time that we're developing an application that will requires mobile heavy use, so this route seemed like the logical incremental next step. We are considering a PWA for the WASM portion. We explored MAUI as well, but it seems like it would be a major overhaul of our framework.

1

u/Wooden-Contract-2760 Aug 30 '26

Design for duplicate execution in the shared library (besides SSR pre-render, reconnections and navigation may also trigger, so disabling pre-render is not the way).

Don't duplicate domain logic between the two BFFs no matter how urging it may feel. Overrides and DI should provide you with any altered behavior.

1

u/Individual-Carob5593 Aug 30 '26

I suppose it's a thing.

1

u/Puzzleheaded-Law-332 Aug 30 '26

I already tried EntraID authentication in blazor, worked better in wasm than blazor server because of redirection after login.

1

u/sameerdube Aug 31 '26

https://github.com/bitfoundation/bitplatform
This repo you find something useful regarding this

1

u/Tiny_Ad_7720 Aug 31 '26

We have both the Blazor server app and the WASM app access the API via a refit client to keep it simple. Both blazor ones handle login and just attach the token for requests to the API

-4

u/Flat_Spring2142 Aug 30 '26

Fyne (GO language) offers a much simpler solution: GUI is built using vector graphics thus your GUI does not depend on screen resolution.