Create Blazor Project
.NET (Microsoft)OfficialPublished by .NET (Microsoft)
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to initializing new Blazor web applications. It guides users through selecting the appropriate interactivity level—ranging from Static SSR to Interactive Auto—and ensures the project is scaffolded with the correct configuration, dependencies, and initial file structure. It also includes instructions for setting up project-specific agent documentation to maintain consistency throughout the development lifecycle.
What it does
- Determines the optimal Blazor render mode based on project requirements.
- Executes the correct dotnet CLI commands to scaffold the project.
- Configures project structure for single-project or multi-project (Client/Server) setups.
- Provides guidance on enabling authentication during the initial setup.
- Standardizes the creation of AGENTS.md files for new projects.
- Ensures Program.cs and App.razor are correctly wired for the chosen interactivity mode.
When to use it
- When starting a new Blazor web application from scratch.
- When you need to decide between Static SSR, Server, WebAssembly, or Auto render modes.
- When you need to scaffold a project with specific authentication requirements.
- When you need to ensure the initial project architecture follows best practices for Blazor.
Advantages
- Prevents common configuration errors by selecting the right render mode early.
- Standardizes project initialization across different development environments.
- Provides clear decision criteria for choosing between server-side and client-side interactivity.
- Ensures essential documentation is created immediately upon project creation.
Usage examples
- “Create a new Blazor web app for a dashboard that needs global server-side interactivity.”
- The agent will run 'dotnet new blazor -o MyDashboard -int Server -ai' and guide you through creating the corresponding AGENTS.md file.
- “I need to start a simple content-focused site with no interactivity. How should I scaffold it?”
- The agent will recommend the 'Static SSR' mode and execute 'dotnet new blazor -o MySite -int None' to ensure the fastest load times.
- “Scaffold a new Blazor project with individual user authentication.”
- The agent will prompt for the desired render mode and then append '-au Individual' to the scaffold command to set up ASP.NET Core Identity.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/dotnet/create-blazor-project/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip create-blazor-project.zip -d .agents/skills
Documentation by .NET (Microsoft)
Create a Blazor Web App
Before You Start — Gather Requirements
If the user's request doesn't make the following clear, ask before scaffolding:
What does the app do? List the main screens/features (e.g., "product catalog with search and shopping cart").
What kind of interactivity is needed? Displaying data and forms? Real-time updates? Offline support? Rich drag-and-drop UI?
Deployment environment? Internet-facing? Intranet? Mobile users on slow connections?
Authentication needed? Anonymous? Individual accounts? Organizational (Azure AD)?
Pick the Right Interactivity Level
Blazor render modes are a progression scale. Start at the simplest level that satisfies the requirements and only move up when there's a concrete reason.
Static SSR ──→ SSR + Enhanced Nav ──→ Interactive Server ──→ Interactive WebAssembly
simplest most complexDecision Rules
| If the app needs... | Use | Why |
|---|---|---|
| Display data, simple forms, links between pages | Static SSR (-int None) | 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 (-int Server) | Only the components that need interactivity opt in with @rendermode. The rest stays static. Server-side execution, full .NET access, no API layer needed. |
| Most pages need rich interactivity (dashboards, drag-and-drop, chat) | Interactive Server, global (-int Server -ai) | 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 (-int WebAssembly) | Code runs in the browser. Eliminates round-trip latency but requires a .Client project, API layer for data access, and downloads the .NET runtime to the browser on first visit. For offline support, enable PWA: add a service worker and manifest after scaffolding (not included in the template by default). |
| Fast initial load (Server) + low latency after (WebAssembly) | Interactive Auto (-int 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. |
Default recommendation: Start with -int Server (per-page). It covers the vast majority of apps. Upgrade to global or WebAssembly only when a specific requirement demands it.
Auto Mode Constraints
Auto mode means your component code runs on the server first, then in the browser on subsequent visits. This creates real constraints:
All interactive components must live in the
.Clientproject — same as WebAssembly.No direct server access from interactive components — no EF
DbContext, no file system, no server-only services. All data access must go through HTTP APIs.Both
Program.csfiles must register matching services — the server and client DI containers must both provide implementations for any service an interactive component injects.Code must not assume its execution environment — no
HttpContextaccess, no browser-only APIs withoutRendererInfoguards.Test in both modes — a component that works on Server during development may break on WebAssembly in production (second visit). Test both paths.
Don'ts
Don't pick WebAssembly "because it's cool" — it adds a
.Clientproject, forces API-mediated data access, and downloads ~10MB to the browser on first visit.Don't pick Auto unless you can articulate why Server alone and WebAssembly alone are both insufficient.
Don't pick global interactivity for apps where most pages are read-only content — per-page keeps the static pages fast and reduces server memory.
Scaffold the Project
Static SSR Only (display data + simple forms)
dotnet new blazor -o {AppName} -int NoneNo interactive runtime. Enhanced navigation enabled by default via blazor.web.js.
Interactive Server, Per-Page (recommended default)
dotnet new blazor -o {AppName} -int ServerPages are static by default. Add @rendermode InteractiveServer to components that need interactivity.
Interactive Server, Global
dotnet new blazor -o {AppName} -int Server -aiAll pages interactive via <Routes @rendermode="InteractiveServer" /> in App.razor.
Interactive WebAssembly, Per-Page
dotnet new blazor -o {AppName} -int WebAssemblyCreates {AppName} (server) and {AppName}.Client (WebAssembly) projects. Interactive components must live in .Client.
Interactive WebAssembly, Global
dotnet new blazor -o {AppName} -int WebAssembly -aiInteractive Auto, Per-Page
dotnet new blazor -o {AppName} -int AutoInteractive Auto, Global
dotnet new blazor -o {AppName} -int Auto -aiWith Authentication
Append -au Individual to any command above:
dotnet new blazor -o {AppName} -int Server -au Individual-au Individual scaffolds ASP.NET Core Identity with SQLite (CLI) or SQL Server (Visual Studio). Identity pages are always static SSR — they do not use interactive render modes.
The blazor template only supports -au Individual. For organizational auth (Microsoft Entra ID, Azure AD B2C), scaffold with -au Individual first, then replace the Identity provider with Microsoft.Identity.Web / OIDC middleware and configure the tenant in appsettings.json.
What the Template Creates
Single project (Static SSR, Server)
{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}.csprojTwo projects (WebAssembly, Auto)
{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.razorRule: Components using InteractiveWebAssembly or InteractiveAuto must live in the .Client project. They can reference shared code but cannot reference server-only types (EF DbContext, server-side services).
Program.cs Wiring
The template generates the correct Program.cs for the chosen mode. Verify these registrations match your intent:
Static SSR Only
// Program.cs
builder.Services.AddRazorComponents();
// ...
app.MapRazorComponents<App>();Server (per-page or global)
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// ...
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();WebAssembly (per-page or global)
// 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 servicesCreate Project AGENTS.md
After scaffolding, create an AGENTS.md file in the project root (next to the .csproj). For two-project setups, put it in the server project root.
Pick the matching template from assets/agents-md/ based on the chosen mode:
| Mode | Template file |
|---|---|
Static SSR (-int None) | assets/agents-md/ssr-none.md |
Server, per-page (-int Server) | assets/agents-md/server-per-page.md |
Server, global (-int Server -ai) | assets/agents-md/server-global.md |
WebAssembly, per-page (-int WebAssembly) | assets/agents-md/webassembly-per-page.md |
WebAssembly, global (-int WebAssembly -ai) | assets/agents-md/webassembly-global.md |
Auto, per-page (-int Auto) | assets/agents-md/auto-per-page.md |
Auto, global (-int Auto -ai) | assets/agents-md/auto-global.md |
Copy the template contents into the project's AGENTS.md and replace every {AppName} with the actual project name. If auth was scaffolded (-au Individual), add an ## Authentication section noting that ASP.NET Core Identity is configured and that Identity pages under Components/Account/ are always static SSR — do not add @rendermode to them.
After scaffolding the project and creating AGENTS.md, continue implementing the features the user requested. Remove default template pages (Counter, Weather) and replace them with the actual application pages.
Auto (per-page or global)
// Server Program.cs
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
// ...
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof({AppName}.Client._Imports).Assembly);App.razor — Global vs Per-Page
The difference between global and per-page interactivity is entirely in App.razor:
Per-page (default)
<!DOCTYPE html>
<html>
<head>
<HeadOutlet />
</head>
<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
</body>
</html>No @rendermode on <Routes> or <HeadOutlet>. Individual pages opt in.
Global
<!DOCTYPE html>
<html>
<head>
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
<Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
</body>
</html>Replace InteractiveServer with InteractiveWebAssembly or InteractiveAuto as appropriate.
After Scaffolding
Verify it builds:
dotnet buildRun it:
dotnet run(in the server project if two-project setup)Add your first page: Create a
.razorfile inComponents/Pages/(server project) orPages/(.Clientproject for WebAssembly components)
Don'ts
Don't use
dotnet new blazorwasm— that creates a standalone WebAssembly SPA without server-side rendering. Use theblazortemplate with-int WebAssemblyinstead.Don't manually add
AddInteractiveServerComponents()to a project created with-int Noneand expect it to work — you also need the@rendermodedirectives and potentiallyApp.razorchanges. Re-scaffold if the mode needs to change fundamentally.Don't put WebAssembly-targeted components in the server project — they'll work during prerender but fail after handoff.
Files
- ATTRIBUTION.mdAdded by AutoGineer855 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md11.9 KiB
- assets/agents-md/auto-global.md2.8 KiB
- assets/agents-md/auto-per-page.md2.9 KiB
- assets/agents-md/server-global.md1.5 KiB
- assets/agents-md/server-per-page.md1.8 KiB
- assets/agents-md/ssr-none.md1.7 KiB
- assets/agents-md/webassembly-global.md2.5 KiB
- assets/agents-md/webassembly-per-page.md2.6 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- .NET (Microsoft)
- Publisher
- .NET (Microsoft) (Official)
- Source
- dotnet/skills · plugins/dotnet-blazor/skills/create-blazor-project · commit 96c3d68
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by .NET (Microsoft).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download create-blazor-project.zip