main banner

Development

Blazor, a goodbye from .Net developers to JS Frameworks?

I’ve been a .Net developer for quite some time and in recent years I’ve seen the buzz of the appearance of front-end frameworks such as React, Angular, Vue, etc. 


As you might agree, the current trend for us as developers is to become full-stack. If you’re a back-end developer, it could be challenging to keep up with learning JS frameworks. So, when I heard about Microsoft releasing this new member of the ASP.NET family named Blazor, I felt really excited.

 

In the next section, I’ll try to give an overview of what Blazor is about.

 

What is Blazor?

Blazor is a front-end development framework that uses C# instead of JavaScript.

 

With Blazor you’re able to create an app composed of reusable components implemented using C#, HTML, and CSS.

 

It allows you to write client-side application code with C# without having to rely on JavaScript as we do with Jquery, React, Angular, Vue, etc. So we basically use C# to write client and server code. 

 

How Blazor can run client-side C#?

Blazor comes in two flavors:

  • Blazor Server (supported in ASP.Net Core 3.0)

With Blazor server, the components are processed in the server, not in the client. The UI updates and client events are managed/handled by a mechanism that uses a SignalR connection to work.

  • Blazor Web Assembly (still on preview for ASP.NET Core 3.1) 

The client-side C# code is run directly on the browser by using Web Assembly.

 

Javascript interoperability

I found the fact that if you need to access JavaScript libraries or interact with the browser APIs you can call JavaScript code from C# and vice versa very interesting.

 

What do I need to get started with Blazor?

You need to install the latest .NET Core 3.0 SDK release.

 

If you’re using Visual Studio, you only need to follow the process to create a new project, select Blazor App, and then choose the Blazor Server App Template.

 

If you want to use the .NET Core CLI, you can use the following command:

 

dotnet new blazorserver -o WebApplication1

 

As mentioned in previous sections, only Blazor Server is supported on .NET Core 3.0. If you want to work with Blazor Web Assembly, you need to install .NET Core 3.1 Preview SDK.

 

Blazor Server Template example

I created a repository that contains an empty Blazor Server project just to give you an idea of how it looks like. It was created with Visual Studio using the Blazor Server App template.

 

Blazor is still on its early stages, but it seems to be a very promising approach for back-end developers that are already familiar with C#, so they can move to the front-end side of development without having to learn a JS framework.

 

Do you think Blazor will help Dot Net developers forget about learning JS Frameworks? Please let me know what you think in the comments section.

 

References: 
Roth, Daniel, and Luke Latham. “Introduction to ASP.NET Core Blazor.” Introduction to ASP.NET Core Blazor, 12 Apr. 2019, https://docs.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-3.0.

Raul Aguilera

The Beatles fan and guitar player.

Articles