Layouts can be placed on both the server and client side, and each page can choose which layout it wants to use. SSR pages on the server can use layouts on the client. As far as I know (AFAIK), SSR pages are just interactive components/pages minus events, i.e., you have the full component life cycle and properties/methods, etc.
I have not found what I would call a "have your cake and eat it" mode after spending the last four days trying God knows how many different combinations of settings and component locations.
Given your comments, my assumption is that you would like pretty much the old client Web Assembly project with server-side API and a few SSR pages. If that is the case, then yes, this is possible, but there are a couple of gotchas to take into account.
Take a quick look at the new project templates and select the Web Assembly/global project with individual accounts (just for pointers). This will create SSR pages on the server, with a router and other stuff on the client. The magic for this is in the App.razor file on the server:
private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account") ? null : InteractiveWebAssembly;
A null render mode means it's an SSR page.
Now, create your own Web Assembly/global project without the account stuff and alter the App.razor so you can have WASM with SSR pages; it all works fine. Now for the quirks.
- You are on your WASM pages, navigating with or without the internet; all is good; it's cached on the client side.
- You navigate to an SSR page; it goes to the server, and the App.Razor server page is run, and then your SSR page; all is well.
The quirks/gotchas:
- You navigate to a WASM page, it goes back to the server and does the whole prerender thing and then runs on the client again. I have not found a way to stop this behaviour; I do not know why it needs to do this.
4a. You are on the SSR page, and you lose the internet connection; you now cannot navigate anywhere; you are just stuck on the SSR page until the internet comes back.
4b. You lose the internet while on WASM (no problem); you navigate to the SSR page and get the "You're not connected page"; you then try to go back to your cached WASM pages; nothing works; you are stuck on the not connected page until the internet comes back.
4b is not too much of an issue; just check for the internet before navigation. 4a not sure how to solve this one, and 3 just bugs the hell out of me.
All of the new project template selections/types have varying degrees of quirks and gotchas.
I have spent the last year and a half with the old-style WASM and API server path (with gRPC), no prerendering or Blazor server, without problem.
The new auto per component project is very appealing, but it is no silver bullet. It's the route I will probably go unless requirements dictate otherwise. But the last four days spent banging my head against a brick wall with the varying options and gotchas have shown me what code-arounds I would need to put in place to make things work the way I want (excluding the fetch to the server even with navigating between WASM pages). So, I am prepared if I do decide to go that route.
Please post your findings. I, for one, would be grateful for any additional findings by others, so I know more about what I would be facing depending on the project selection.
Hope my findings are of some use.
StaticLayout.razorfor static SSR pages andInteractiveLayout.razorfor interactive pages. Heve you tried this way?