Blazor Hybrid Web App
This page covers the mixed Blazor Web App scenario where one app hosts both server-rendered DrawnUI and browser/WASM DrawnUI.
What "Hybrid" Means Here
In this repository, hybrid means:
- a Blazor Web App host that supports both
InteractiveServerandInteractiveWebAssembly - a
.Clientproject for the WebAssembly-side component graph - DrawnUI runtime choice made at component boundaries
It does not mean nesting one interactive mode inside an already-interactive parent of another mode.
Validated Pattern
The validated pattern is a static or SSR host page that mounts sibling components with different render modes.
Current working sample:
src/Blazor/Samples/BlazorSandboxHybrid/
The /hybrid route validates:
- one sibling
InteractiveServerDrawnUI panel - one sibling
InteractiveWebAssemblyDrawnUI panel - standard Blazor button updates in both panels
- DrawnUI button interactions in both panels
Project Shape
Typical mixed-app structure:
- server host project references
DrawnUi.Blazor.Server .Clientproject referencesDrawnUi.Blazor.Wasm- components rendered with
InteractiveWebAssemblylive in the client-side graph - server-only DrawnUI panels can live in the host or in a server-side RCL
Host Setup
using BlazorSandboxHybrid.Components;
using DrawnUi.Blazor.Server;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
builder.Services.AddDrawnUiBlazorServer();
var app = builder.Build();
app.MapStaticAssets();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode();
app.Run();
Example Page Shape
<div class="hybrid-grid">
<section>
<ServerDrawnPanel />
</section>
<section>
<WasmDrawnPanel @rendermode="wasmMode" />
</section>
</div>
@code {
private static readonly IComponentRenderMode wasmMode = new InteractiveWebAssemblyRenderMode(prerender: false);
}
In the current sample, the server panel carries its own InteractiveServer render boundary and the WASM panel is mounted as a sibling island.
Important Rules
- choose runtime at the component boundary
- do not try to switch a child component to a different interactive mode than an already-interactive parent
- components using
InteractiveWebAssemblymust come from the client-side project graph - mixed hosts may still need the core browser asset project in graph so
_content/DrawnUi.Blazor.Core/*assets are served for the WASM-side DrawnUI runtime
When To Use This Pattern
Use this pattern when:
- some DrawnUI surfaces are event-driven and acceptable as server-owned frame rendering
- other DrawnUI surfaces need local browser responsiveness
- you want gradual adoption instead of forcing the whole app into one rendering model
Live Sample
Use the hosted sample to demonstrate the mixed server + browser runtime split: