MobileBlazorBindings icon indicating copy to clipboard operation
MobileBlazorBindings copied to clipboard

Add Blazor Mobile Blazor Bindings to existing Blazor WASM project

Open vallgrenerik opened this issue 4 years ago • 5 comments

Hi @Eilon, @danroth27 and @SteveSandersonMS. I'm about to choose framework for a future project. As of now I'm really leaning to choose Blazor WASM since it looks really promising.

But in the future my customer would like to have push notifications (since it's not currently available through PWA on iOS) and maybe some other platform specific sensor that's only reachable through a native app (or Xamarin...). In the future, if Mobile Blazor Bindings becomes a LTS, do you see any showstoppers to add a Mobile Blazor Bindings project to a existing Blazor project. If we create our components in a seperate component library, independently from the target framework, would this be possible?

I understand that this is hypothetically but what are your thoughts? :) Thanks in advance and hope you'll have a nice day!

vallgrenerik avatar Jan 20 '21 11:01 vallgrenerik

Apart from the developers, I'd like to make an explanation here.

What you need is Razor Class Library, if you don't know it already.

You will create your razor components including _Import and App razor files. Then you will have 2 seperate projects as Blazor WASM and Blazor Hybrid (and its 4 subprojects for iOS, Android, Windows and MacOS). They will reference your rcl project. If your project is responsive enough, it should be good to go. Carry all your razor components from WASM project to RCL. In your Hybrid and WASM entry points, you'll be referencing the App.razor inside the RCL.

I've published one of my apps to the AppStore and Play Store. And there are some others on the way.

idylmz avatar Jan 29 '21 13:01 idylmz

Pretty much what @idylmz said.

The choice of Blazor Server vs. Blazor WebAssembly (WASM) vs. Mobile Blazor Bindings Hybrid Apps is mostly independent of your Blazor code. Most stuff works the same everywhere. If you place your Blazor code in a Razor Class Library (RCL) Project then you can reference that RCL from a Blazor app project (Server, WASM, MBB Hybrid) and it'll run the same.

Eilon avatar Jan 29 '21 21:01 Eilon

Also please note that Mobile Blazor Bindings is an experimental project with no firm timeline for release. But we are working on Desktop support (Windows and macOS) for hybrid apps for .NET 6: https://github.com/dotnet/aspnetcore/issues/27217

Eilon avatar Jan 29 '21 21:01 Eilon

Thank you @idylmz and @Eilon! I know MBB is experimental, but if I structure my code in the way @idylmz said the project will have better seperation. So in the future, if my customer wants a native (iOS/Android) app, the reuseability would be in better shape right? :) Thanks in advance!

vallgrenerik avatar Jan 31 '21 10:01 vallgrenerik

@vallgrenerik yes that should be true.

Eilon avatar Feb 01 '21 21:02 Eilon