A Pratical Scenario Where Blazor Server Is the BEST Option
As YouTubers and content creators, we often create tutorials to explain new technologies and provide access and information to learn them.
However, sometimes, there is a gap between the tutorial and the real world.
Yes, we need to simplify things and make assumptions. Otherwise, we wouldn’t get to the core of the problem, and explaining simple things would take much longer than the attention span of today’s world.
But this newsletter allows me to share stories that you cannot find anywhere else. Not because they aren’t there. But because you most likely wouldn’t pay attention.
The Problem
I have a project where I will implement a dashboard displaying data from home automation sensors. Another company builds the home automation system and stores values in a relational database.
The user should be able to log into the application and see the current values of different sensors, as well as historical data and a graphical representation of them (charts).
The Options
Desktop applications don’t make much sense in this scenario. We don’t need access to hardware and don’t want to limit ourselves to a specific operating system or deal with cross-platform requirements to build a simple dashboard.
Web applications are the cross-platform technology with the lowest barrier to entry. We don’t need a specific programming language or toolset.
We can use JavaScript, C#, or any other web development technology for the interaction code. Also, we don’t have an expensive and complicated installation procedure. The user opens a URL, and the application is just there.
Why Blazor Server
This takes us to the question of what web technology to choose for the project in mind.
I have more than 5 years of experience with React and TypeScript. Previously, it was my standard toolset for building single-page web applications.
During the last few years, I learned more and more about Blazor. Blazors strength is that we can use C#, a compiled programming language to implement our interaction logic. In my opinion, compiled programming languages have many advantages over interpreted languages, such as build stability, performance, and many more.
When it comes to Blazor, we have Blazor Server and Blazor WebAssembly as two different options. Blazor Server allows us to implement the client and server code within a single project.
Yes, we use HTML and CSS for our user interface definition, but all interaction code executes on the server. This architecture allows us to skip an API layer.
We all learned to have a backend providing an API and a client consuming that API. For most applications, the relation between those two components is a 1-on-1 relation. It means that we have a single client for a single API. There is a lot of overhead involved when you think of it. With Blazor Server, we don’t need that.
Blazor WebAssembly runs on the client. Therefore, we need an API layer and have the same overhead compared to a JavaScript or TypeScript-based solution such as React or Angular. Also, Blazor WebAssembly has many debugging and other issues.
Considering all those facts and assumptions, Blazor Server allows for rapid software development, a simple architecture, and a web application based on open web standards, HTML, and CSS. And the best part is that we can use C#, one of the best and most widely used programming languages.
Are there limitations? Yes. Blazor Server requires more server resources than other options. And it also depends on how many concurrent users the application needs to handle. For my scenario, 10 concurrent users are all we need. Do you build the next Facebook or Google? It’s probably not for you. Also, Blazor Server requires an ASP.NET Core application as the host of the application.
Conclusion
Sometimes, it’s worth thinking outside the box and, instead of using the same architecture again and again, being open to trying something new.
Is Blazor Server the holy grail for web development? No.
Will I use Blazor Server for all upcoming web projects? No.
Will I consider it depending on several factors and requirements? Yes.
Let me know about your experience with Blazor.
If you want to learn more about Blazor, here are a few videos that I think are worth watching.