How to use both Blazor client and server in same web
Asked Answered
M

2

8

I'm learning about the Blazor, and see benefit of 2 types client-side and server-side.

I want to use both on the same web e.g. one path is a client-side WebAssembly app, another path is a server-side that run code in server.

I have seen Blazor Full-Stack template (not quite understand) but it missing from latest templates package. Did they remove it on purpose? (only 2 left Blazor Server App and Blazor WebAssembly App)

I download templates from this command.

dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview9.19465.2

Can client-side and server-side work together?

Maxiemaxilla answered 27/9, 2019 at 9:27 Comment(2)
Did you read this #58119374 ?Chapatti
No. You have to choose one or the other. Either way it's still Blazor, so there's nothing to signal which one would be used where. The difference lies in the underlying implementations (SignalR vs. Web Assembly).Pauper
H
2

It is not officially supported or build, but, it is in theory possible. However, it is something they are looking into.

Source (start watching from 28:35): https://youtu.be/qF6ixMjCzHA?t=1715

Heng answered 28/9, 2019 at 1:21 Comment(2)
can you add information from video to the answer, please?Friedrick
Was there any development in this direction?Sulphurous
P
5

This is now possible in .NET 8 using the new Blazor render modes. You can now setup the render location (i.e. Blazor Server or Blazor Client/WebAssembly) independently for every page and every components, simply by using the following directives:

For Blazor Server:

@rendermode InteractiveServer

For Blazor WebAssembly:

@rendermode InteractiveWebAssembly

And it's even possible to have a page/component that renders in the server for the very first load, then renders in client/WebAssembly for all the next loads, so the user is not slowed down by the WebAssembly package loading during the first load, using:

@rendermode InteractiveAuto

For more info, see here.

Prolusion answered 15/11, 2023 at 15:13 Comment(1)
this is not simply true. dont mislead with this answer. there are several rules and restrictions for that.Carlsen
H
2

It is not officially supported or build, but, it is in theory possible. However, it is something they are looking into.

Source (start watching from 28:35): https://youtu.be/qF6ixMjCzHA?t=1715

Heng answered 28/9, 2019 at 1:21 Comment(2)
can you add information from video to the answer, please?Friedrick
Was there any development in this direction?Sulphurous

© 2022 - 2024 — McMap. All rights reserved.