Introduction
Blazor, part of ASP.NET Core, is a versatile framework used for building interactive web applications. It offers two main hosting models: Blazor Server and Blazor WebAssembly (WASM). Here's how developers are using Blazor and the considerations for each model:
Blazor Server
Blazor Server runs the application on the server, sending UI updates to the client via SignalR. This model is beneficial for applications that require quick initial load times and can handle the server load.
Use Cases:
- Internal Business Applications: "I transferred an Angular application I built to Blazor. I like Blazor better for internal business applications."
- Dashboards: "I also have two Blazor Server projects at work that are basically dashboards for some automated data import and processing jobs."
- Prototyping: "Server is great for prototyping since it runs fast and debugging works everywhere."
Challenges:
- Connection Stability: "A few have complained about losing connection in bad internet spots."
- Scalability: "First of all I would not use Blazor server for that many users. That's a lot of sockets to maintain open at once."
Blazor WebAssembly (WASM)
Blazor WASM runs the application directly in the browser using WebAssembly, which can be beneficial for reducing server load and enabling offline capabilities.
Use Cases:
- Client-Side Applications: "I have a side project in Blazor WASM that modifies an NES ROM according to some settings the user specifies."
- Static Hosting: "I really like that all the data manipulation code can just run in the browser, and it can be hosted as static files with no need for a server application."
- Mobile-Friendly Applications: "I found that my admins like to work directly from their mobile devices which has presented a problem."
Challenges:
- Initial Load Time: "The startup load times are just too high."
- Complexity: "Blazor WASM needs a bigger initial download."
Hybrid and Unified Approaches
With .NET 8, Blazor introduces a unified approach that combines the benefits of both server and client-side rendering.
Unified Blazor Web App: "Blazor Web App can use both Server and WASM, is there reason why you might not use this template in favor of the Blazor Web Assembly template?" Auto Mode: "We now have auto mode, which starts your site as Blazor server and then switches to wasm."
Conclusion
Blazor offers flexibility for various use cases, from internal business applications to client-side projects. The choice between Blazor Server and Blazor WASM depends on specific project requirements, such as connection stability, scalability, and initial load times.