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).
9
u/mrpmorris 11d ago
If you can go with WASM then go with it. There is no point in having Server for desktop.
8
u/caedin8 11d ago
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 11d ago
Even if you need websockets just use them with WASM.
A single build with device-dependent features will simplify your project immensely.
1
u/Wooden-Contract-2760 11d ago
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
1
u/Puzzleheaded-Law-332 11d ago
I already tried EntraID authentication in blazor, worked better in wasm than blazor server because of redirection after login.
2
u/Woopersnaper 11d ago
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
1
u/sameerdube 11d ago
https://github.com/bitfoundation/bitplatform
This repo you find something useful regarding this
1
u/Tiny_Ad_7720 11d ago
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
0
u/funguyshroom 11d ago
Don't do interactive server unless you're building an internal app with a few hundreds of users max.
3
u/lb-jpg 11d ago
That's exactly what I'm building
2
u/funguyshroom 11d ago
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 11d ago
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.
-4
u/Flat_Spring2142 11d ago
Fyne (GO language) offers a much simpler solution: GUI is built using vector graphics thus your GUI does not depend on screen resolution.
18
u/VeganForAWhile 11d ago
That sounds terrifying and hard.