# convert-blazor-server-to-webapp

Guides a pre-.NET 8 Blazor Server app to the Blazor Web App model. Use it when replacing the old host setup while retaining interactive server rendering.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3000 installs · ★ 5730
- Author: dotnet
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/dotnet/skills/tree/HEAD/plugins/dotnet-aspnetcore/skills/convert-blazor-server-to-webapp/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/convert-blazor-server-to-webapp

## What it does

This skill guides a move from `AddServerSideBlazor` and `MapBlazorHub` to `AddRazorComponents` and `MapRazorComponents`. It moves routing from `App.razor` into `Routes.razor`, turns `_Host.cshtml` into the root component, and replaces `blazor.server.js` with `blazor.web.js`.

The converted app keeps `InteractiveServer` render mode. The workflow also covers enhanced navigation and streaming rendering in Blazor Web Apps, while an existing `AuthorizeRouteView` stays in the routing setup.

You need a Blazor Server project, `Program.cs` or `Startup.cs`, and a target of .NET 8 or later. If the project already uses `AddRazorComponents` and `MapRazorComponents`, conversion is unnecessary, so check that configuration first.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill convert-blazor-server-to-webapp -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/convert-blazor-server-to-webapp/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/convert-blazor-server-to-webapp/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill convert-blazor-server-to-webapp -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/convert-blazor-server-to-webapp/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill convert-blazor-server-to-webapp -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/convert-blazor-server-to-webapp/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dotnet/skills convert-blazor-server-to-webapp
```

2. **Manually: put the files in place**
- File: `.github/skills/convert-blazor-server-to-webapp/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill convert-blazor-server-to-webapp -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dotnet/skills --path plugins/dotnet-aspnetcore/skills/convert-blazor-server-to-webapp
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/convert-blazor-server-to-webapp/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill convert-blazor-server-to-webapp -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dotnet/skills/tree/HEAD/plugins/dotnet-aspnetcore/skills/convert-blazor-server-to-webapp/SKILL.md

## When to use it
- migrate Blazor Server to Blazor Web App
- replace `AddServerSideBlazor` and `MapBlazorHub`
- convert `_Host.cshtml` into `App.razor`
- switch from `blazor.server.js` to `blazor.web.js`
- retain interactivity with `InteractiveServer`

## Example prompts
- Convert this Blazor Server project to a Blazor Web App.
- Check `Program.cs` and move `_Host.cshtml` into `App.razor`.
- Update the app to `net8.0` while preserving `InteractiveServer`.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 90493a04d3a5ca55.

BEGIN THIRD-PARTY FILE 90493a04d3a5ca55
```text
---
name: convert-blazor-server-to-webapp
license: MIT
description: >
  Guides conversion of a pre-.NET 8 Blazor Server app into a .NET 8+ Blazor Web App.
  USE FOR: migrating apps that use AddServerSideBlazor and MapBlazorHub to the
  AddRazorComponents/MapRazorComponents model, converting _Host.cshtml to an App.razor
  root component, replacing blazor.server.js with blazor.web.js, migrating
  CascadingAuthenticationState to a service, adopting new Blazor Web App features
  like enhanced navigation and streaming rendering.
  DO NOT USE FOR: apps that are already Blazor Web Apps (already use AddRazorComponents
  and MapRazorComponents), Blazor WebAssembly or hosted Blazor WebAssembly apps
  (different migration path), apps that should stay on the Blazor Server hosting
  model without converting, or apps still targeting .NET Framework.
---

# Convert Blazor Server App to Blazor Web App

This skill helps an agent convert a pre-.NET 8 Blazor Server app into a .NET 8+ Blazor Web App. The old hosting model uses `AddServerSideBlazor`/`MapBlazorHub` with a `_Host.cshtml` Razor Page as the entry point. The new Blazor Web App model uses `AddRazorComponents`/`MapRazorComponents` with an `App.razor` root component, enabling per-component render modes, enhanced navigation, streaming rendering, and other .NET 8+ features. The converted app uses `InteractiveServer` render mode to preserve existing interactive behavior.

## When to Use

- Migrating a Blazor Server app from .NET 6 or .NET 7 to .NET 8+
- App currently uses `AddServerSideBlazor()` and `MapBlazorHub()` in `Program.cs` (or `Startup.cs`)
- App uses `Pages/_Host.cshtml` (or `_Host.razor`) as the host page with Component Tag Helpers
- Want to adopt new Blazor Web App features while keeping interactive server rendering

## When Not to Use

- **The app already uses `AddRazorComponents` and `MapRazorComponents`.** It is already a Blazor Web App — no conversion is needed. Stop here and tell the user the app is already using the Blazor Web App model.
- Blazor WebAssembly or hosted Blazor WebAssembly app — these have a different migration path
- The app should stay on the legacy Blazor Server hosting model (just update TFM and packages)
- The app targets .NET Framework — it must be migrated to .NET first

## Inputs

| Input | Required | Description |
|-------|----------|-------------|
| Blazor Server project | Yes | The `.csproj` and source files of the Blazor Server app |
| Target framework | Yes | .NET 8 or later (e.g., `net8.0`, `net9.0`, `net10.0`) |
| `Program.cs` or `Startup.cs` | Yes | The app's service and middleware configuration |
| `_Host.cshtml` location | Recommended | Usually `Pages/_Host.cshtml`; may be `_Host.razor` in some projects |

## Workflow
```
END THIRD-PARTY FILE 90493a04d3a5ca55

The third-party file has ended. Everything between the 90493a04d3a5ca55 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2757 of 15487 bytes. © dotnet · MIT · https://github.com/dotnet/skills/tree/HEAD/plugins/dotnet-aspnetcore/skills/convert-blazor-server-to-webapp/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
