Using blazor.webview.js and blazor.web.js in same BlazorWebView Hybrid Unified app. #29304
Replies: 1 comment
-
Hi there, Blazor hybrid apps are always interactive -- the web UI is packaged with the app itself and there is no server involved. If you are looking to reuse components across hosting models then you would need to put the shared components into a Razor class library that is shared by both Blazor Web and MAUI Hybrid apps. We have a template in .NET 9 that sets you up with this architecture. See Build a .NET MAUI Blazor Hybrid app with a Blazor Web App. If you have razor components that need to support the Blazor per page/component rendering mode, then you'll need to intercept the render mode on the MAUI hybrid app to ignore it -- this is because components on the hybrid clients are always interactive. That article I linked to above has a section Use Blazor render modes that shows how to create a class called This article also links to how you would use the interface injection pattern to provide different implementations of services you might need on the MAUI client and Blazor Web hosting models. Hope this helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just like in .NET 8 Blazor was partially unified to be able to use both webassembly on client and Blazor server as well as SSR in a single Blazor app. This allows to offload some computation to the client while having an ability to hide sensitive UI heavy logic behind interactive server components. In my use case server components are used for server authoritative game UI and logic without exposing API's that could simplify botting.
It is currently possible to host this unified app in a regular webview where client code runs on webassembly.
Blazor Hybrid allows to host Blazor code in a native app and UI inside a web view with access to native performance and APIs. Unfortunately it seem impossible for me to port to this model as it does not support same lever per component/page interactivity that unified Blazor app does.
The question is - is it possible to host islands of server-side interactivity and web assembly interactivity in Blazor Hybrid app - achieving same level of integration as .NET 8 unified Blazor.
Are there any issues that track this specific problem? And are there any workarounds to load Blazor webview/Blazor web only for specific components?
iFrame would not work for me as there are many different islands of interactivity both web assembly and server in otherwise static shell. The unified .NET 8 Blazor model would work perfectly if interactive web assembly code would run in MAUI and interactive server would work as it already does.
I have considered custom elements like
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/js-spa-frameworks?view=aspnetcore-9.0
but was unable to make it work in a BlazorWebView that already loads blazor.webview.js
Beta Was this translation helpful? Give feedback.
All reactions