Blazor WebAssembly vs Server which is better?

Admin | Last updated 09/04/2024

Blazor comes with multiple hosting models (render modes)

Till .Net 7, we had Blazor WebAssembly and Blazor Server

Which is better is totally depends on your requirements

Here is a brief comparison of both

Blazor Server

    

Blazor WebAssembly (Blazor WASM)    

Blazor Server is a Asp.Net Core App, so it has all the benefits of Asp.Net Core App including MiddlewaresBlazor WebAssembly is true client side Single Page App, it does not have Asp.Net Core container
Blazor Server can directly connect to database and file systemBlazor WebAssembly runs in client browser, so it does not have direct access to server resources like database and file system
(We need and Api layer in order to connect to some database or server file system)    
It uses SignalR for interactivityIt does not need SignalR for interactivity. It uses Web Assembly for interactivity, which is downloaded in the browser    
It needs an active connection to the server for SignalR, so server consumption is always there    It is fully client side, it does not need any active connection to the server    
First request is faster as it does not need to download blazor code to the client    First request is relatively slower as it downloads the .net runtime and blazor app's code to browser on the initial request    
It is relatively slower for user interactions, as each and every action goes to the server over SignalR and then the response comes back via the same SignalR connection, and then it updates the uiIt is relatively faster for user interactions, as everything happens in the client browser only, so no server roundtrip for interactivity    
This is much secure as everything runs on server    It is also secure, but not a good place to store the secret information. We need and additional layer (Api layer)    
For Deployment - It needs Asp.Net Runtime        For Deployment-  It is true client side rendered single page app (SPA) so it does not need any runtime. It can be hosted on any static file server
Not good for large number of concurrent users, because of active SignalR connections on the server    Not of concurrent users does not make any difference, as there is no load on server
The application is server rendered so good for SEO    Application is not server rendered


After this comparison, you can decide which is good for you.
Both has their own pros and cons.



Comments

No comments yet. Be the first to leave a comment

Add a New Comment
An unhandled error has occurred. Reload 🗙