Explain the Double Render problem during prerendering: why does OnInitializedAsync run twice, and how do you prevent side effects or flickering?

Last updated 5 July 2026

  • With prerendering, a component renders once on the server (static HTML) and again on the client with a fresh instance, so OnInitializedAsync runs twice. This causes duplicate side effects and flicker as data is refetched.

  • Use PersistentComponentState to carry the server-fetched data to the client so it reuses it instead of refetching.

  • Guard non-idempotent side effects with RendererInfo.IsInteractive or move them to OnAfterRenderAsync(firstRender) (client-only). As a last resort, set prerender: false.

  • https://www.youtube.com/watch?v=qQ91rdMgIMM
  • https://juliocasal.com/blog/dealing-with-blazor-prerendering
  • https://alexb72.medium.com/prerendering-in-blazor-how-to-persist-state-using-persistingcomponentstate-6a1ead059aa0
  • https://learn.microsoft.com/en-us/aspnet/core/blazor/state-management/prerendered-state-persistence?view=aspnetcore-10.0
  • https://jonhilton.net/persist-state-between-renders-net8/
  • https://learn.microsoft.com/en-us/answers/questions/1621494/why-is-oninitializedasync-called-twice-on-a-page-r
  • https://supportcenter.devexpress.com/ticket/details/t1217363/a-new-project-created-with-wizard-calls-the-oninitializedasync-event-twice
  • https://blazor-university.com/components/component-lifecycles/
All Blazor interview questions