fsbolero / Bolero

Bolero brings Blazor to F# developers with an easy to use Model-View-Update architecture, HTML combinators, hot reloaded templates, type-safe endpoints, advanced routing and remoting capabilities, and more.
https://fsbolero.io
Apache License 2.0
1.05k stars 53 forks source link

Running Blazor component on client #201

Open profK opened 3 years ago

profK commented 3 years ago

Hi,

I've been working through with Bolero but Ive run into a bit of a stumbling block. I want complete control on the client without elmish or any other framework in the way.

I get that I can use a Blazor Component as MyApp, but how do I get Bolero to run it on WASM rather then remotely on the server?

JaggerJo commented 3 years ago

Hi @profK!

I want complete control on the client without elmish or any other framework in the way.

No problemo, you can directly derive from Component (which itself derives from aspnet core's ComponentBase and just sprinkles a few methods ontop that help with rendering)

type App() =
    inherit Component()

    override this.Render() =
        div [] [
            p [] [textf "Hello World and welcome to my app!"]
        ]

I get that I can use a Blazor Component as MyApp, but how do I get Bolero to run it on WASM rather then remotely on the server?

Actually with the default Bolero templates it already runs client side in Web-assembly. Blazor offers several different hosting modes, mainly Server Side Blazor / Razor Components and Blazor Web-assembly.

https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-5.0