Loading...
Loading...
Create a new ASP.NET Core web application or web site using Blazor. USE FOR: creating a new Blazor web app, scaffolding a new web project, starting a new web site, choosing render modes (Static SSR, Interactive Server, Interactive WebAssembly, Auto), running dotnet new blazor with the right options, setting up initial project structure. DO NOT USE FOR: adding features to existing projects, changing how an existing app renders, or component authoring (use author-component).
npx skill4agent add dotnet/skills create-blazor-projectStatic SSR ──→ SSR + Enhanced Nav ──→ Interactive Server ──→ Interactive WebAssembly
simplest most complex| If the app needs... | Use | Why |
|---|---|---|
| Display data, simple forms, links between pages | Static SSR ( | No JS runtime, no circuit, no WebAssembly download. Forms work via HTML POST. Enhanced navigation makes it feel snappy. |
| Everything above + a few components with client-side behavior (live search, real-time updates, complex form wizards) | Interactive Server, per-page ( | Only the components that need interactivity opt in with |
| Most pages need rich interactivity (dashboards, drag-and-drop, chat) | Interactive Server, global ( | Every component is interactive by default. Consistent UX, simpler mental model. Trade-off: every user holds a SignalR circuit on the server. |
| Network latency is a problem, users are on mobile/poor connections, or the app must work offline | Interactive WebAssembly ( | Code runs in the browser. Eliminates round-trip latency but requires a |
| Fast initial load (Server) + low latency after (WebAssembly) | Interactive Auto ( | First visit uses Server; subsequent visits use cached WebAssembly runtime. Most complex setup — see Auto constraints below. Only choose when both Server and WebAssembly constraints apply. |
-int Server.ClientDbContextProgram.csHttpContextRendererInfo.Clientdotnet new blazor -o {AppName} -int Noneblazor.web.jsdotnet new blazor -o {AppName} -int Server@rendermode InteractiveServerdotnet new blazor -o {AppName} -int Server -ai<Routes @rendermode="InteractiveServer" />App.razordotnet new blazor -o {AppName} -int WebAssembly{AppName}{AppName}.Client.Clientdotnet new blazor -o {AppName} -int WebAssembly -aidotnet new blazor -o {AppName} -int Autodotnet new blazor -o {AppName} -int Auto -ai-au Individualdotnet new blazor -o {AppName} -int Server -au Individual-au Individualblazor-au Individual-au IndividualMicrosoft.Identity.Webappsettings.json{AppName}/
├── Components/
│ ├── App.razor # Root component — sets <HeadOutlet> and <Routes>
│ ├── Routes.razor # Wraps <Router> with route discovery
│ ├── Layout/
│ │ ├── MainLayout.razor # App shell with nav, header, footer
│ │ └── MainLayout.razor.css
│ └── Pages/
│ └── Home.razor # @page "/" — first page
├── Program.cs # Service registration and middleware
├── wwwroot/ # Static files (CSS, images)
└── {AppName}.csproj{AppName}/ # Server project — hosts the app
├── Components/ # Server-only components (static SSR pages, layouts)
│ ├── App.razor
│ ├── Routes.razor
│ └── Layout/
├── Program.cs # Server Program.cs
└── {AppName}.Client/ # Client project — WebAssembly components
├── Pages/ # Interactive components go HERE
├── Program.cs # Client Program.cs
└── _Imports.razorInteractiveWebAssemblyInteractiveAuto.ClientDbContextProgram.cs// Program.cs
builder.Services.AddRazorComponents();
// ...
app.MapRazorComponents<App>();builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// ...
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();// Server Program.cs
builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents();
// ...
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof({AppName}.Client._Imports).Assembly);// Client Program.cs
builder.Services.AddAuthorizationCore();
// Register HttpClient, other client-side servicesAGENTS.md.csprojassets/agents-md/| Mode | Template file |
|---|---|
Static SSR ( | |
Server, per-page ( | |
Server, global ( | |
WebAssembly, per-page ( | |
WebAssembly, global ( | |
Auto, per-page ( | |
Auto, global ( | |
AGENTS.md{AppName}-au Individual## AuthenticationComponents/Account/@rendermode// Server Program.cs
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
// ...
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof({AppName}.Client._Imports).Assembly);App.razor<!DOCTYPE html>
<html>
<head>
<HeadOutlet />
</head>
<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
</body>
</html>@rendermode<Routes><HeadOutlet><!DOCTYPE html>
<html>
<head>
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
<Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
</body>
</html>InteractiveServerInteractiveWebAssemblyInteractiveAutodotnet builddotnet run.razorComponents/Pages/Pages/.Clientdotnet new blazorwasmblazor-int WebAssemblyAddInteractiveServerComponents()-int None@rendermodeApp.razor