Svelte Vs Blazor

Posted on  by admin

Find out the benefits of Blazor over Angular, React and other JavaScript frameworks. Blazor enables sharing code across client- and server-side processes, server-side rendering functionality and more.

When building a single-page application, Angular or React are popular JavaScript frameworks to use. And up until now, the majority of client-side processes are written using JavaScript.

However, there is an evolving framework that will allow you to write client-side processes using C#.

Blazor is a .NET framework for creating a single-page application that allows you to create your application using C#, Razor and HTML. The client-side of Blazor uses WebAssembly, which has been shipped with major browser engines, such as Internet Explorer, Chrome, Safari and Firefox.

WebAssembly is an alternative to JavaScript in writing client-side code.

  • And it can be converted using many different programming languages.

In Blazor’s instance, it is converted using C#. The integration of Blazor and WebAssembly gives you a different way of building a single-page application with the same results.

So why should you choose Blazor over a JavaScript framework? At present, Blazor comes with two hosting models. The first is Blazor Server. Blazor Server allows the application to be executed at server-side. Layout changes, event handling and JavaScript calls are done through a SignalR connection. The other is Blazor WebAssembly.

Blazor WebAssembly allows you to run the application client-side with the use of WebAssembly. If you need to integrate server-side functionality, you can either run it alongside Blazor Server, or you can use a separate API application.


Below is an example of running Blazor WebAssembly through a separate API application. When the page is initialized, it will display a list of technologies. These technologies are loaded through the API. Additionally, we have a text box and a button.

  • When we enter some text and press the button, our entered text is sent to the API and returns an updated list of technologies. Unlike Blazor, with a JavaScript framework, you always need to have a separate application if you wish to have server-side functionality.
  • As Blazor WebAssembly allows you to write client-side code in C#, this means that any developers working on your application may only need to know one language.
  • This can have many benefits, particularly if you are responsible for running a Blazor project.

Only needing to know one coding language means knowing the skills that you need your team members to be proficient in. It also makes it easier to assign roles to your team members, knowing there won't be a coding language barrier.

  • We are going to put some client-side coding in action.
  • We display the current time on the page. When we press the button, the time is updated with the current time.
  • All written in C#. No sign of JavaScript anywhere!

To integrate this with a JavaScript library, you would have to build and integrate an API request to get the current server time. Thereafter, you would have to build the process of updating the time through the relevant JavaScript framework language.