convert-blazor-server-to-webapp

Migrates pre-.NET 8 Blazor Server apps to the .NET 8+ Blazor Web App model.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill convert-blazor-server-to-webapp-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: convert-blazor-server-to-webapp
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/convert-blazor-server-to-webapp
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill convert-blazor-server-to-webapp-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Migrating a legacy Blazor Server application to the modern Blazor Web App model involves many coordinated changes across the project file, Program.cs, _Host.cshtml, and App.razor, and missing any step causes broken rendering, failed form posts, or lost circuit configuration. ## Core Features & Use Cases - Step-by-step migration workflow: Converts AddServerSideBlazor/MapBlazorHub to AddRazorComponents/MapRazorComponents, transforms _Host.cshtml into an App.razor root component, and moves the Router into Routes.razor. - Authentication and middleware handling: Replaces the CascadingAuthenticationState component wrapper with the AddCascadingAuthenticationState service and adds the required UseAntiforgery middleware. - Validation checklist and pitfalls: Verifies no legacy APIs remain (blazor.server.js, MapFallbackToPage, _Host.cshtml) and documents common failures like missing antiforgery middleware or incorrect prerendering behavior. - Use Case: You have a .NET 7 Blazor Server app using Pages/_Host.cshtml and want to upgrade to .NET 8 with InteractiveServer render mode while preserving existing interactive behavior. ## Quick Start Ask the agent to convert this Blazor Server project to a .NET 8 Blazor Web App using InteractiveServer render mode.

Frequently Asked Questions about convert-blazor-server-to-webapp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a Blazor Server app to a Blazor Web App in .NET 8?

Update the TFM to net8.0, replace AddServerSideBlazor with AddRazorComponents().AddInteractiveServerComponents(), replace MapBlazorHub with MapRazorComponents<App>().AddInteractiveServerRenderMode(), and convert _Host.cshtml into an App.razor root component with a Routes.razor file for the Router.

How to migrate _Host.cshtml to App.razor in Blazor?

Move the HTML shell from _Host.cshtml into App.razor, remove Razor Page directives and Tag Helpers, replace Component Tag Helpers with HeadOutlet and Routes components using InteractiveServer render mode, change the base href to "/", and swap blazor.server.js for blazor.web.js.

Does this migration work for Blazor WebAssembly apps?

No, Blazor WebAssembly and hosted Blazor WebAssembly apps follow a different migration path and are out of scope. This workflow only covers Blazor Server apps using AddServerSideBlazor and MapBlazorHub moving to the InteractiveServer render mode.

Why do form POST requests return 400 errors after migrating to Blazor Web App?

The antiforgery middleware is missing from the pipeline. AddRazorComponents registers antiforgery services automatically, but you must explicitly add app.UseAntiforgery() after UseAuthentication and UseAuthorization for form posts to succeed.

What replaces CascadingAuthenticationState in Blazor Web Apps?

The component wrapper does not work across render mode boundaries, so register builder.Services.AddCascadingAuthenticationState() in Program.cs instead. This provides Task<AuthenticationState> as a cascading value to all components regardless of render mode.

When should I not convert a Blazor Server app to a Blazor Web App?

Skip conversion if the app already uses AddRazorComponents and MapRazorComponents, if it should remain on the legacy Blazor Server hosting model with only a TFM update, or if it still targets .NET Framework and must be migrated to .NET first.