user6826023
user6826023

Reputation:

How to use both Blazor client and server in same web

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?

Upvotes: 8

Views: 5192

Answers (2)

Rémi Gaudin
Rémi Gaudin

Reputation: 514

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.

Upvotes: 5

Neville Nazerane
Neville Nazerane

Reputation: 7049

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

Upvotes: 2

Related Questions