[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EKVGRD808R3TGTPT58N6P7":3,"skill-same:01M7EKVGRD808R3TGTPT58N6P7":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":14,"repositoryHtmlUrl":35,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":51},"01M7EKVGRD808R3TGTPT58N6P7","support-prerendering",null,"Make interactive Blazor components work correctly with prerendering. USE FOR fixing duplicate data loads, UI flicker during prerender-to-interactive handoff, null references during prerender, persisting state across prerender, disabling prerendering, excluding","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fcloud\u002Fsupport-prerendering\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: support-prerendering\ndescription: \"Make interactive Blazor components work correctly with prerendering. USE FOR fixing duplicate data loads, UI flicker during prerender-to-interactive handoff, null references during prerender, persisting state across prerender, disabling prerendering, excluding\"\ncategory: cloud\nversion: 1.0.0\ndisable-model-invocation: false\nrisk: low\nsource:\n  repository: \"microsoft\u002Fskills\"\n  commit: \"8f3b1a2c\"\n  path: \"plugins\u002Fdotnet-blazor\u002Fskills\u002Fsupport-prerendering\u002FSKILL.md\"\n  license: \"MIT\"\n  imported_at: \"2026-09-20\"\n---\n# Support Prerendering\n\n## How Prerendering Works\n\nPrerendering is **on by default** for all interactive render modes. The server renders the component as static HTML and ships it to the browser immediately. Then the interactive runtime (Server\u002FWebAssembly) loads and re-renders the component with full interactivity.\n\nThis means:\n- `OnInitializedAsync` runs **twice** — once during prerender (static), once when the interactive runtime attaches.\n- `OnAfterRenderAsync` is **NOT** called during prerender — only after the interactive render.\n- Internal navigation between interactive pages (interactive routing) **skips prerendering** — prerendering only happens on full page loads.\n\n## Step 1 — Read the Project's AGENTS.md\n\nCheck the project's `AGENTS.md` for the **Interactivity Mode** and **Interactivity Scope**:\n\n| Mode | Prerendering applies? |\n|------|----------------------|\n| None (Static SSR) | No — there's no interactive handoff |\n| Server | Yes |\n| WebAssembly | Yes |\n| Auto | Yes |\n\nIf the mode is `None`, this skill doesn't apply.\n\n## Persist State Across Prerender → Interactive\n\nThe most common prerendering problem: data loaded in `OnInitializedAsync` during prerender is thrown away and re-fetched when the interactive runtime attaches. This causes flicker and duplicate API\u002FDB calls.\n\n### Recommended: `[PersistentState]` attribute\n\nAnnotate properties to automatically serialize during prerender and restore on interactive activation:\n\n```razor\n@page \"\u002Fforecasts\"\n@rendermode InteractiveServer\n\n\u003Ch1>Weather\u003C\u002Fh1>\n\n@if (Forecasts is null)\n{\n    \u003Cp>Loading...\u003C\u002Fp>\n}\nelse\n{\n    @foreach (var f in Forecasts)\n    {\n        \u003Cp>@f.Date: @f.TemperatureC°C\u003C\u002Fp>\n    }\n}\n\n@code {\n    [PersistentState]\n    public WeatherForecast[]? Forecasts { get; set; }\n\n    protected override async Task OnInitializedAsync()\n    {\n        Forecasts ??= await ForecastService.GetForecastsAsync();\n    }\n}\n```\n\nThe `??=` pattern is critical — it means \"only fetch if the property wasn't already restored from prerender state.\"\n\n### Multiple instances of the same component\n\nWhen the same component type appears multiple times, use `@key` to disambiguate state:\n\n```razor\n@foreach (var item in items)\n{\n    \u003CItemCard @key=\"item.Id\" \u002F>\n}\n```\n\n### Advanced: `PersistentComponentState` service\n\nFor complex scenarios (dynamic keys, custom serialization), use the imperative API:\n\n```csharp\n@inject PersistentComponentState ApplicationState\n\n@code {\n    private List\u003COrder>? orders;\n\n    protected override async Task OnInitializedAsync()\n    {\n        ApplicationState.RegisterOnPersisting(PersistOrders);\n\n        if (!ApplicationState.TryTakeFromJson\u003CList\u003COrder>>(\"orders\", out var restored))\n        {\n            orders = await OrderService.GetOrdersAsync();\n        }\n        else\n        {\n            orders = restored;\n        }\n    }\n\n    private Task PersistOrders()\n    {\n        ApplicationState.PersistAsJson(\"orders\", orders);\n        return Task.CompletedTask;\n    }\n}\n```\n\n## Disable Prerendering\n\nDisable prerendering when a component depends on browser APIs immediately or when the prerender+interactive double render causes problems you can't solve with `[PersistentState]`.\n\n### On a component definition\n\n```razor\n@rendermode @(new InteractiveServerRenderMode(prerender: false))\n```\n\nReplace `InteractiveServerRenderMode` with `InteractiveWebAssemblyRenderMode` or `InteractiveAutoRenderMode` as needed.\n\n### On a component instance\n\n```razor\n\u003CMyChart @rendermode=\"new InteractiveServerRenderMode(prerender: false)\" \u002F>\n```\n\n### On the entire app\n\nIn `App.razor`:\n\n```razor\n\u003CHeadOutlet @rendermode=\"new InteractiveServerRenderMode(prerender: false)\" \u002F>\n\u003CRoutes @rendermode=\"new InteractiveServerRenderMode(prerender: false)\" \u002F>\n```\n\nNote: A parent's prerendering setting overrides children. If `\u003CRoutes>` disables prerendering, individual pages cannot re-enable it.\n\n## Exclude Pages from Interactive Routing\n\nIn a globally interactive app, some pages may need `HttpContext` (cookies, request headers, response status codes). These pages must render via static SSR, not inside the interactive runtime.\n\nUse `[ExcludeFromInteractiveRouting]`:\n\n```razor\n@page \"\u002Fprivacy\"\n@attribute [ExcludeFromInteractiveRouting]\n\n\u003Ch1>Privacy Policy\u003C\u002Fh1>\n```\n\nThis forces a **full page reload** when navigating to this page, exiting interactive routing. The page renders as static SSR with full `HttpContext` access.\n\nIn `App.razor`, conditionally apply the render mode:\n\n```razor\n\u003C!DOCTYPE html>\n\u003Chtml>\n\u003Chead>\n    \u003CHeadOutlet @rendermode=\"RenderModeForPage\" \u002F>\n\u003C\u002Fhead>\n\u003Cbody>\n    \u003CRoutes @rendermode=\"RenderModeForPage\" \u002F>\n    \u003Cscript src=\"_framework\u002Fblazor.web.js\">\u003C\u002Fscript>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n\n@code {\n    [CascadingParameter]\n    public HttpContext HttpContext { get; set; } = default!;\n\n    private IComponentRenderMode? RenderModeForPage =>\n        HttpContext.AcceptsInteractiveRouting() ? InteractiveServer : null;\n}\n```\n\nReplace `InteractiveServer` with the app's configured render mode.\n\n## Detect Prerender vs Interactive at Runtime\n\nUse `RendererInfo` to guard code that should only run interactively:\n\n```csharp\nprotected override async Task OnInitializedAsync()\n{\n    if (RendererInfo.IsInteractive)\n    {\n        \u002F\u002F Only runs during the interactive render, not during prerender\n        await StartSignalRConnection();\n    }\n}\n```\n\n`RendererInfo` properties:\n- `IsInteractive` — `false` during prerender, `true` after interactive runtime attaches\n- `Name` — `\"Static\"` during prerender, `\"Server\"` or `\"WebAssembly\"` when interactive\n\n## Client Services Fail During Prerender\n\nComponents in the `.Client` project prerender on the server. Services registered only in the client `Program.cs` (e.g., `IWebAssemblyHostEnvironment`) won't be available during prerender.\n\nFix by one of:\n1. **Register a matching service on the server** — both `Program.cs` files provide the service\n2. **Make the service optional** — use constructor injection with a nullable default: `public MyComponent(IMyService? svc = null)`\n3. **Create a service abstraction** — interface in `.Client`, implementations in both projects\n4. **Disable prerendering** for that component\n\n## Don'ts\n\n- Don't call JS interop in `OnInitializedAsync` — JS isn't available during prerender. Use `OnAfterRenderAsync(firstRender)`.\n- Don't assume `OnInitializedAsync` runs once — it runs twice with prerendering. Always use `[PersistentState]` or `??=` guards.\n- Don't use `HttpContext` in interactive components — it's only available during the static prerender, not during the interactive lifetime. Use `[ExcludeFromInteractiveRouting]` for pages that need it.\n- Don't disable prerendering as a first resort — it hurts perceived load time and SEO. Use `[PersistentState]` to preserve state instead.\n","# Support Prerendering\n\n## How Prerendering Works\n\nPrerendering is **on by default** for all interactive render modes. The server renders the component as static HTML and ships it to the browser immediately. Then the interactive runtime (Server\u002FWebAssembly) loads and re-renders the component with full interactivity.\n\nThis means:\n- `OnInitializedAsync` runs **twice** — once during prerender (static), once when the interactive runtime attaches.\n- `OnAfterRenderAsync` is **NOT** called during prerender — only after the interactive render.\n- Internal navigation between interactive pages (interactive routing) **skips prerendering** — prerendering only happens on full page loads.\n\n## Step 1 — Read the Project's AGENTS.md\n\nCheck the project's `AGENTS.md` for the **Interactivity Mode** and **Interactivity Scope**:\n\n| Mode | Prerendering applies? |\n|------|----------------------|\n| None (Static SSR) | No — there's no interactive handoff |\n| Server | Yes |\n| WebAssembly | Yes |\n| Auto | Yes |\n\nIf the mode is `None`, this skill doesn't apply.\n\n## Persist State Across Prerender → Interactive\n\nThe most common prerendering problem: data loaded in `OnInitializedAsync` during prerender is thrown away and re-fetched when the interactive runtime attaches. This causes flicker and duplicate API\u002FDB calls.\n\n### Recommended: `[PersistentState]` attribute\n\nAnnotate properties to automatically serialize during prerender and restore on interactive activation:\n\n```razor\n@page \"\u002Fforecasts\"\n@rendermode InteractiveServer\n\n\u003Ch1>Weather\u003C\u002Fh1>\n\n@if (Forecasts is null)\n{\n    \u003Cp>Loading...\u003C\u002Fp>\n}\nelse\n{\n    @foreach (var f in Forecasts)\n    {\n        \u003Cp>@f.Date: @f.TemperatureC°C\u003C\u002Fp>\n    }\n}\n\n@code {\n    [PersistentState]\n    public WeatherForecast[]? Forecasts { get; set; }\n\n    protected override async Task OnInitializedAsync()\n    {\n        Forecasts ??= await ForecastService.GetForecastsAsync();\n    }\n}\n```\n\nThe `??=` pattern is critical — it means \"only fetch if the property wasn't already restored from prerender state.\"\n\n### Multiple instances of the same component\n\nWhen the same component type appears multiple times, use `@key` to disambiguate state:\n\n```razor\n@foreach (var item in items)\n{\n    \u003CItemCard @key=\"item.Id\" \u002F>\n}\n```\n\n### Advanced: `PersistentComponentState` service\n\nFor complex scenarios (dynamic keys, custom serialization), use the imperative API:\n\n```csharp\n@inject PersistentComponentState ApplicationState\n\n@code {\n    private List\u003COrder>? orders;\n\n    protected override async Task OnInitializedAsync()\n    {\n        ApplicationState.RegisterOnPersisting(PersistOrders);\n\n        if (!ApplicationState.TryTakeFromJson\u003CList\u003COrder>>(\"orders\", out var restored))\n        {\n            orders = await OrderService.GetOrdersAsync();\n        }\n        else\n        {\n            orders = restored;\n        }\n    }\n\n    private Task PersistOrders()\n    {\n        ApplicationState.PersistAsJson(\"orders\", orders);\n        return Task.CompletedTask;\n    }\n}\n```\n\n## Disable Prerendering\n\nDisable prerendering when a component depends on browser APIs immediately or when the prerender+interactive double render causes problems you can't solve with `[PersistentState]`.\n\n### On a component definition\n\n```razor\n@rendermode @(new InteractiveServerRenderMode(prerender: false))\n```\n\nReplace `InteractiveServerRenderMode` with `InteractiveWebAssemblyRenderMode` or `InteractiveAutoRenderMode` as needed.\n\n### On a component instance\n\n```razor\n\u003CMyChart @rendermode=\"new InteractiveServerRenderMode(prerender: false)\" \u002F>\n```\n\n### On the entire app\n\nIn `App.razor`:\n\n```razor\n\u003CHeadOutlet @rendermode=\"new InteractiveServerRenderMode(prerender: false)\" \u002F>\n\u003CRoutes @rendermode=\"new InteractiveServerRenderMode(prerender: false)\" \u002F>\n```\n\nNote: A parent's prerendering setting overrides children. If `\u003CRoutes>` disables prerendering, individual pages cannot re-enable it.\n\n## Exclude Pages from Interactive Routing\n\nIn a globally interactive app, some pages may need `HttpContext` (cookies, request headers, response status codes). These pages must render via static SSR, not inside the interactive runtime.\n\nUse `[ExcludeFromInteractiveRouting]`:\n\n```razor\n@page \"\u002Fprivacy\"\n@attribute [ExcludeFromInteractiveRouting]\n\n\u003Ch1>Privacy Policy\u003C\u002Fh1>\n```\n\nThis forces a **full page reload** when navigating to this page, exiting interactive routing. The page renders as static SSR with full `HttpContext` access.\n\nIn `App.razor`, conditionally apply the render mode:\n\n```razor\n\u003C!DOCTYPE html>\n\u003Chtml>\n\u003Chead>\n    \u003CHeadOutlet @rendermode=\"RenderModeForPage\" \u002F>\n\u003C\u002Fhead>\n\u003Cbody>\n    \u003CRoutes @rendermode=\"RenderModeForPage\" \u002F>\n    \u003Cscript src=\"_framework\u002Fblazor.web.js\">\u003C\u002Fscript>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n\n@code {\n    [CascadingParameter]\n    public HttpContext HttpContext { get; set; } = default!;\n\n    private IComponentRenderMode? RenderModeForPage =>\n        HttpContext.AcceptsInteractiveRouting() ? InteractiveServer : null;\n}\n```\n\nReplace `InteractiveServer` with the app's configured render mode.\n\n## Detect Prerender vs Interactive at Runtime\n\nUse `RendererInfo` to guard code that should only run interactively:\n\n```csharp\nprotected override async Task OnInitializedAsync()\n{\n    if (RendererInfo.IsInteractive)\n    {\n        \u002F\u002F Only runs during the interactive render, not during prerender\n        await StartSignalRConnection();\n    }\n}\n```\n\n`RendererInfo` properties:\n- `IsInteractive` — `false` during prerender, `true` after interactive runtime attaches\n- `Name` — `\"Static\"` during prerender, `\"Server\"` or `\"WebAssembly\"` when interactive\n\n## Client Services Fail During Prerender\n\nComponents in the `.Client` project prerender on the server. Services registered only in the client `Program.cs` (e.g., `IWebAssemblyHostEnvironment`) won't be available during prerender.\n\nFix by one of:\n1. **Register a matching service on the server** — both `Program.cs` files provide the service\n2. **Make the service optional** — use constructor injection with a nullable default: `public MyComponent(IMyService? svc = null)`\n3. **Create a service abstraction** — interface in `.Client`, implementations in both projects\n4. **Disable prerendering** for that component\n\n## Don'ts\n\n- Don't call JS interop in `OnInitializedAsync` — JS isn't available during prerender. Use `OnAfterRenderAsync(firstRender)`.\n- Don't assume `OnInitializedAsync` runs once — it runs twice with prerendering. Always use `[PersistentState]` or `??=` guards.\n- Don't use `HttpContext` in interactive components — it's only available during the static prerender, not during the interactive lifetime. Use `[ExcludeFromInteractiveRouting]` for pages that need it.\n- Don't disable prerendering as a first resort — it hurts perceived load time and SEO. Use `[PersistentState]` to preserve state instead.\n",{"name":5,"risk":24,"source":25,"version":30,"category":31,"description":7,"disable-model-invocation":20},"low",{"path":26,"commit":27,"license":15,"repository":28,"imported_at":29},"plugins\u002Fdotnet-blazor\u002Fskills\u002Fsupport-prerendering\u002FSKILL.md","8f3b1a2c","microsoft\u002Fskills","2026-09-20","1.0.0","cloud","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fcloud\u002Fsupport-prerendering","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill support-prerendering",{"tool":44,"command":45},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill support-prerendering",{"tool":47,"command":48},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill support-prerendering","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fcloud\u002Fsupport-prerendering\u002FSKILL.md",true,[],[53,61,68,75,82,89],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":60},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":60},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":60},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":60},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":60},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":60},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]