{"slug":"create-blazor-project","title":"create-blazor-project","summary":"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 wit","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-24T05:37:36.974415Z","repo":{"url":"https://github.com/dotnet/skills","stars":6296,"forks":500,"license":"MIT","updatedAt":"2026-11-19T18:23:42Z"},"bodyHtml":"<hr>\n<h2>license: MIT\nname: create-blazor-project\ndescription: &gt;\nCreate a new ASP.NET Core web application or web site using Blazor.\nUSE FOR: creating a new Blazor web app, scaffolding a new web project,\nstarting a new web site, choosing render modes (Static SSR, Interactive Server,\nInteractive WebAssembly, Auto), running dotnet new blazor with the right options,\nsetting up initial project structure.\nDO NOT USE FOR: adding features to existing projects, changing how an existing\napp renders, or component authoring (use author-component).</h2>\n<h1>Create a Blazor Web App</h1>\n<h2>Before You Start — Gather Requirements</h2>\n<p>If the user's request doesn't make the following clear, ask before scaffolding:</p>\n<ol>\n<li><strong>What does the app do?</strong> List the main screens/features (e.g., \"product catalog with search and shopping cart\").</li>\n<li><strong>What kind of interactivity is needed?</strong> Displaying data and forms? Real-time updates? Offline support? Rich drag-and-drop UI?</li>\n<li><strong>Deployment environment?</strong> Internet-facing? Intranet? Mobile users on slow connections?</li>\n<li><strong>Authentication needed?</strong> Anonymous? Individual accounts? Organizational (Azure AD)?</li>\n</ol>\n<h2>Pick the Right Interactivity Level</h2>\n<p>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.</p>\n<pre><code>Static SSR ──→ SSR + Enhanced Nav ──→ Interactive Server ──→ Interactive WebAssembly\n simplest                                                           most complex\n</code></pre>\n<h3>Decision Rules</h3>\n<table>\n<thead>\n<tr>\n<th>If the app needs...</th>\n<th>Use</th>\n<th>Why</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Display data, simple forms, links between pages</td>\n<td><strong>Static SSR</strong> (<code>-int None</code>)</td>\n<td>No JS runtime, no circuit, no WebAssembly download. Forms work via HTML POST. Enhanced navigation makes it feel snappy.</td>\n</tr>\n<tr>\n<td>Everything above + a few components with client-side behavior (live search, real-time updates, complex form wizards)</td>\n<td><strong>Interactive Server, per-page</strong> (<code>-int Server</code>)</td>\n<td>Only the components that need interactivity opt in with <code>@rendermode</code>. The rest stays static. Server-side execution, full .NET access, no API layer needed.</td>\n</tr>\n<tr>\n<td>Most pages need rich interactivity (dashboards, drag-and-drop, chat)</td>\n<td><strong>Interactive Server, global</strong> (<code>-int Server -ai</code>)</td>\n<td>Every component is interactive by default. Consistent UX, simpler mental model. Trade-off: every user holds a SignalR circuit on the server.</td>\n</tr>\n<tr>\n<td>Network latency is a problem, users are on mobile/poor connections, or the app must work offline</td>\n<td><strong>Interactive WebAssembly</strong> (<code>-int WebAssembly</code>)</td>\n<td>Code runs in the browser. Eliminates round-trip latency but requires a <code>.Client</code> 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).</td>\n</tr>\n<tr>\n<td>Fast initial load (Server) + low latency after (WebAssembly)</td>\n<td><strong>Interactive Auto</strong> (<code>-int Auto</code>)</td>\n<td>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.</td>\n</tr>\n</tbody>\n</table>\n<p><strong>Default recommendation:</strong> Start with <code>-int Server</code> (per-page). It covers the vast majority of apps. Upgrade to global or WebAssembly only when a specific requirement demands it.</p>\n<h3>Auto Mode Constraints</h3>\n<p>Auto mode means your component code runs on the server first, then in the browser on subsequent visits. This creates real constraints:</p>\n<ul>\n<li><strong>All interactive components must live in the <code>.Client</code> project</strong> — same as WebAssembly.</li>\n<li><strong>No direct server access</strong> from interactive components — no EF <code>DbContext</code>, no file system, no server-only services. All data access must go through HTTP APIs.</li>\n<li><strong>Both <code>Program.cs</code> files must register matching services</strong> — the server and client DI containers must both provide implementations for any service an interactive component injects.</li>\n<li><strong>Code must not assume its execution environment</strong> — no <code>HttpContext</code> access, no browser-only APIs without <code>RendererInfo</code> guards.</li>\n<li><strong>Test in both modes</strong> — a component that works on Server during development may break on WebAssembly in production (second visit). Test both paths.</li>\n</ul>\n<h3>Don'ts</h3>\n<ul>\n<li>Don't pick WebAssembly \"because it's cool\" — it adds a <code>.Client</code> project, forces API-mediated data access, and downloads ~10MB to the browser on first visit.</li>\n<li>Don't pick Auto unless you can articulate why Server alone and WebAssembly alone are both insufficient.</li>\n<li>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.</li>\n</ul>\n<h2>Scaffold the Project</h2>\n<h3>Static SSR Only (display data + simple forms)</h3>\n<pre><code>dotnet new blazor -o {AppName} -int None\n</code></pre>\n<p>No interactive runtime. Enhanced navigation enabled by default via <code>blazor.web.js</code>.</p>\n<h3>Interactive Server, Per-Page (recommended default)</h3>\n<pre><code>dotnet new blazor -o {AppName} -int Server\n</code></pre>\n<p>Pages are static by default. Add <code>@rendermode InteractiveServer</code> to components that need interactivity.</p>\n<h3>Interactive Server, Global</h3>\n<pre><code>dotnet new blazor -o {AppName} -int Server -ai\n</code></pre>\n<p>All pages interactive via <code>&lt;Routes @rendermode=\"InteractiveServer\" /&gt;</code> in <code>App.razor</code>.</p>\n<h3>Interactive WebAssembly, Per-Page</h3>\n<pre><code>dotnet new blazor -o {AppName} -int WebAssembly\n</code></pre>\n<p>Creates <code>{AppName}</code> (server) and <code>{AppName}.Client</code> (WebAssembly) projects. Interactive components must live in <code>.Client</code>.</p>\n<h3>Interactive WebAssembly, Global</h3>\n<pre><code>dotnet new blazor -o {AppName} -int WebAssembly -ai\n</code></pre>\n<h3>Interactive Auto, Per-Page</h3>\n<pre><code>dotnet new blazor -o {AppName} -int Auto\n</code></pre>\n<h3>Interactive Auto, Global</h3>\n<pre><code>dotnet new blazor -o {AppName} -int Auto -ai\n</code></pre>\n<h3>With Authentication</h3>\n<p>Append <code>-au Individual</code> to any command above:</p>\n<pre><code>dotnet new blazor -o {AppName} -int Server -au Individual\n</code></pre>\n<p><code>-au Individual</code> 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.</p>\n<p>The <code>blazor</code> template only supports <code>-au Individual</code>. For organizational auth (Microsoft Entra ID, Azure AD B2C), scaffold with <code>-au Individual</code> first, then replace the Identity provider with <code>Microsoft.Identity.Web</code> / OIDC middleware and configure the tenant in <code>appsettings.json</code>.</p>\n<h2>What the Template Creates</h2>\n<h3>Single project (Static SSR, Server)</h3>\n<pre><code>{AppName}/\n├── Components/\n│   ├── App.razor              # Root component — sets &lt;HeadOutlet&gt; and &lt;Routes&gt;\n│   ├── Routes.razor           # Wraps &lt;Router&gt; with route discovery\n│   ├── Layout/\n│   │   ├── MainLayout.razor   # App shell with nav, header, footer\n│   │   └── MainLayout.razor.css\n│   └── Pages/\n│       └── Home.razor         # @page \"/\" — first page\n├── Program.cs                 # Service registration and middleware\n├── wwwroot/                   # Static files (CSS, images)\n└── {AppName}.csproj\n</code></pre>\n<h3>Two projects (WebAssembly, Auto)</h3>\n<pre><code>{AppName}/                     # Server project — hosts the app\n├── Components/                # Server-only components (static SSR pages, layouts)\n│   ├── App.razor\n│   ├── Routes.razor\n│   └── Layout/\n├── Program.cs                 # Server Program.cs\n└── {AppName}.Client/          # Client project — WebAssembly components\n    ├── Pages/                 # Interactive components go HERE\n    ├── Program.cs             # Client Program.cs\n    └── _Imports.razor\n</code></pre>\n<p><strong>Rule:</strong> Components using <code>InteractiveWebAssembly</code> or <code>InteractiveAuto</code> must live in the <code>.Client</code> project. They can reference shared code but cannot reference server-only types (EF <code>DbContext</code>, server-side services).</p>\n<h2>Program.cs Wiring</h2>\n<p>The template generates the correct <code>Program.cs</code> for the chosen mode. Verify these registrations match your intent:</p>\n<h3>Static SSR Only</h3>\n<pre><code>// Program.cs\nbuilder.Services.AddRazorComponents();\n\n// ...\n\napp.MapRazorComponents&lt;App&gt;();\n</code></pre>\n<h3>Server (per-page or global)</h3>\n<pre><code>builder.Services.AddRazorComponents()\n    .AddInteractiveServerComponents();\n\n// ...\n\napp.MapRazorComponents&lt;App&gt;()\n    .AddInteractiveServerRenderMode();\n</code></pre>\n<h3>WebAssembly (per-page or global)</h3>\n<pre><code>// Server Program.cs\nbuilder.Services.AddRazorComponents()\n    .AddInteractiveWebAssemblyComponents();\n\n// ...\n\napp.MapRazorComponents&lt;App&gt;()\n    .AddInteractiveWebAssemblyRenderMode()\n    .AddAdditionalAssemblies(typeof({AppName}.Client._Imports).Assembly);\n</code></pre>\n<pre><code>// Client Program.cs\nbuilder.Services.AddAuthorizationCore();\n// Register HttpClient, other client-side services\n</code></pre>\n<h2>Create Project AGENTS.md</h2>\n<p>After scaffolding, create an <code>AGENTS.md</code> file in the project root (next to the <code>.csproj</code>). For two-project setups, put it in the server project root.</p>\n<p>Pick the matching template from <code>assets/agents-md/</code> based on the chosen mode:</p>\n<table>\n<thead>\n<tr>\n<th>Mode</th>\n<th>Template file</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Static SSR (<code>-int None</code>)</td>\n<td><code>assets/agents-md/ssr-none.md</code></td>\n</tr>\n<tr>\n<td>Server, per-page (<code>-int Server</code>)</td>\n<td><code>assets/agents-md/server-per-page.md</code></td>\n</tr>\n<tr>\n<td>Server, global (<code>-int Server -ai</code>)</td>\n<td><code>assets/agents-md/server-global.md</code></td>\n</tr>\n<tr>\n<td>WebAssembly, per-page (<code>-int WebAssembly</code>)</td>\n<td><code>assets/agents-md/webassembly-per-page.md</code></td>\n</tr>\n<tr>\n<td>WebAssembly, global (<code>-int WebAssembly -ai</code>)</td>\n<td><code>assets/agents-md/webassembly-global.md</code></td>\n</tr>\n<tr>\n<td>Auto, per-page (<code>-int Auto</code>)</td>\n<td><code>assets/agents-md/auto-per-page.md</code></td>\n</tr>\n<tr>\n<td>Auto, global (<code>-int Auto -ai</code>)</td>\n<td><code>assets/agents-md/auto-global.md</code></td>\n</tr>\n</tbody>\n</table>\n<p>Copy the template contents into the project's <code>AGENTS.md</code> and replace every <code>{AppName}</code> with the actual project name. If auth was scaffolded (<code>-au Individual</code>), add an <code>## Authentication</code> section noting that ASP.NET Core Identity is configured and that Identity pages under <code>Components/Account/</code> are always static SSR — do not add <code>@rendermode</code> to them.</p>\n<p><strong>After scaffolding the project and creating AGENTS.md, continue implementing the features the user requested.</strong> Remove default template pages (Counter, Weather) and replace them with the actual application pages.</p>\n<h3>Auto (per-page or global)</h3>\n<pre><code>// Server Program.cs\nbuilder.Services.AddRazorComponents()\n    .AddInteractiveServerComponents()\n    .AddInteractiveWebAssemblyComponents();\n\n// ...\n\napp.MapRazorComponents&lt;App&gt;()\n    .AddInteractiveServerRenderMode()\n    .AddInteractiveWebAssemblyRenderMode()\n    .AddAdditionalAssemblies(typeof({AppName}.Client._Imports).Assembly);\n</code></pre>\n<h2>App.razor — Global vs Per-Page</h2>\n<p>The difference between global and per-page interactivity is entirely in <code>App.razor</code>:</p>\n<h3>Per-page (default)</h3>\n<pre><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;HeadOutlet /&gt;\n&lt;/head&gt;\n&lt;body&gt;\n    &lt;Routes /&gt;\n    &lt;script src=\"_framework/blazor.web.js\"&gt;&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n<p>No <code>@rendermode</code> on <code>&lt;Routes&gt;</code> or <code>&lt;HeadOutlet&gt;</code>. Individual pages opt in.</p>\n<h3>Global</h3>\n<pre><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;HeadOutlet @rendermode=\"InteractiveServer\" /&gt;\n&lt;/head&gt;\n&lt;body&gt;\n    &lt;Routes @rendermode=\"InteractiveServer\" /&gt;\n    &lt;script src=\"_framework/blazor.web.js\"&gt;&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n<p>Replace <code>InteractiveServer</code> with <code>InteractiveWebAssembly</code> or <code>InteractiveAuto</code> as appropriate.</p>\n<h2>After Scaffolding</h2>\n<ol>\n<li><strong>Verify it builds:</strong> <code>dotnet build</code></li>\n<li><strong>Run it:</strong> <code>dotnet run</code> (in the server project if two-project setup)</li>\n<li><strong>Add your first page:</strong> Create a <code>.razor</code> file in <code>Components/Pages/</code> (server project) or <code>Pages/</code> (<code>.Client</code> project for WebAssembly components)</li>\n</ol>\n<h2>Don'ts</h2>\n<ul>\n<li>Don't use <code>dotnet new blazorwasm</code> — that creates a standalone WebAssembly SPA without server-side rendering. Use the <code>blazor</code> template with <code>-int WebAssembly</code> instead.</li>\n<li>Don't manually add <code>AddInteractiveServerComponents()</code> to a project created with <code>-int None</code> and expect it to work — you also need the <code>@rendermode</code> directives and potentially <code>App.razor</code> changes. Re-scaffold if the mode needs to change fundamentally.</li>\n<li>Don't put WebAssembly-targeted components in the server project — they'll work during prerender but fail after handoff.</li>\n</ul>\n","files":[{"path":"assets/agents-md/auto-global.md","sizeBytes":2866,"isText":true},{"path":"assets/agents-md/auto-per-page.md","sizeBytes":3000,"isText":true},{"path":"assets/agents-md/server-global.md","sizeBytes":1497,"isText":true},{"path":"assets/agents-md/server-per-page.md","sizeBytes":1814,"isText":true},{"path":"assets/agents-md/ssr-none.md","sizeBytes":1696,"isText":true},{"path":"assets/agents-md/webassembly-global.md","sizeBytes":2552,"isText":true},{"path":"assets/agents-md/webassembly-per-page.md","sizeBytes":2702,"isText":true},{"path":"SKILL.md","sizeBytes":12153,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-24T05:42:03.393225Z","sha256":"6F7C92AC91B702CBFEECE29060EBC4E160A13F45B9C53419C3D265D4FC3D9A12","sizeBytes":12441},"review":null,"source":{"repositoryUrl":"https://github.com/dotnet/skills","path":"plugins/dotnet-blazor/skills/create-blazor-project","license":"MIT","commit":"4e03bfdade5d1f9b7d1c2e95f64e31d1cb7af5ab","subtreeSha":"333E0C2FDD42D3709BEE63DA186F866C60F1D7D05F0A7D04D8FF6FBB793279A5","lastSyncedAt":"2026-11-19T19:30:03.195544Z"},"reviewedAt":"2026-08-24T05:53:23.453344Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/dotnet/skills/tree/main/plugins/dotnet-blazor/skills/create-blazor-project"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install dotnet-skills@llmmart"},{"target":"git","command":"git clone https://github.com/dotnet/skills.git"}]}