Search code examples
c#blazorblazor-webassemblymaui

Could Blazor be used exclusively for GUI rendering in native applications instead of XAML?


I am thinking should I invest my time and energy to learning of Blazor. AFAIK initially Blazor was the framework for development of the web applications, but it moving towards native applications.

Let me clarify that:

  • I already have enough good stack (TypeScript + frameworks) for development of Web applications and I don't need the Blazor as alternative
  • I don't need the server functionality of Blazor - ASP.NET is O'K for my needs

What I want from Blazor is taking care about GUI rendering in native applications (.NET MAUI, for example) instead of XAML. Why it is great is:

  • HTML+CSS is more flexible than XAML
  • I can reuse my HTML+CSS developments in native applications

Talking about native application using the Web View we need to clearly below two cases:

  1. The frontend web application which being executed inside Web View. Being the web application, it could NOT:

    • work with local files
    • use local database (please don't tell me about IndexedDB - it's off-topic)
    • use the native API
    • work offline

    As native application, such applications has no value and in most cases could be replaced with PWA.

  2. The Web View is being used only for GUI rendering while Web View could interact with native API, work with local files, local databases etc. Such concept implemented in Electron.JS but it does not support the mobile devices.

I am hope on 2nd functionality from Blazor.

Note about Blazor Hybrid

Maybe it is what I want, but I am not sure. For example, it has the Web compound (wwwroot directory).

enter image description here

If there is the web version, either it it could be completely different with native applications or the native version will have same limitations as web version (e. g. working with local file system etc.)


Solution

  • .NET MAUI Blazor or Blazor Hybrid will run as a .NET application. The only thing that is still web about it is the UI. So I guess that is the short answer to your question: if you use .NET MAUI Blazor, you are using HTML & CSS for GUI rendering, while the rest is running as a .NET application.

    Because we can run the .NET runtime on mobile devices through .NET MAUI, there is no need to spin up some kind of server process or use WebAssembly, it can run directly as a .NET application.

    That also means you are not bound to the browser sandbox. If you want to use the camera? You can! Geolocation? No problem! Format the harddrive? Go for it! Depending on what is supported on a platform and if you implement the right permissions of course. It's still a (mobile) app.

    The cool thing is that it's all still Blazor, so if you make the right code sharing choices, you can easily share all your code between any Blazor web project and the .NET MAUI Blazor project.

    The .NET MAUI Blazor project indeed has web components, since Blazor is essentially a web technology, that's where it all began and to be able to easily transport that to the native apps, that has just been adopted.

    Hope that clears it up!