Open Tarmil opened 5 years ago
@Tarmil is this not working already?
Yes, now that the server side uses Razor, this is supported. It could use some documentation though 😄
@Tarmil I think we still have a problem. I am still working on that pizza workshop. I use client side + prerendering. What happens is , the links are prerendered, but pizza specials content is fetched via WASM. I am kinda confused.
How are the pizza specials retrieved? Via a remote function called from the update? If so, then yeah it's expected that they'll be retrieved from the client.
What you would need to do is call the remote during initialization, because that is run by the prerender. Unfortunately that is currently not possible with the synchronous Program
, but with a hypothetical asynchronous AsyncProgram
, you could do something like the following:
override this.AsyncProgram = async {
let remote = this.Remote<PizzaApi>()
let! specials = remote.GetSpecials()
return Program.mkProgram (initModel specials) (update remote) view
}
This would call GetSpecials
from the server-side prerender, which would allow it to populate the initial HTML correctly. Since this is a server-side call, it is done locally.
Unfortunately the client side would then need to call it again, this time as a proper remote. But at least the full content would be displayed during loading.
@Tarmil Is that hypothetical async program currently possible in Bolero (albeit with the shortcoming of the client doing a duplicate request/rendering)?
Blazor supports server-side prerendering, for example: https://github.com/danroth27/ClientSideBlazorWithPrerendering. It assumes a Razor-based server side, so there should be a bit of plumbing to get it working from F#.