Blazor · Foundations

Blazor Server-Side Rendering

Static server-side rendering (static SSR) is the default in a Blazor Web App: components render to HTML on the server, like a classic web page.

Beginner 5 min Lesson 4 of 31Examples target .NET 9 Blazor Web App.
Before you start:Blazor Architecture
0/31 in Blazor
On this page · 5 min · Beginner

Learning objectives#

  • Explain static SSR and when to use it
  • Use streaming rendering for slow data
  • Handle forms without interactivity
  • Understand enhanced navigation

Explanation#

With static SSR a component renders once per request to plain HTML. No WebSocket and no WebAssembly download — great for content pages and SEO.

Enhanced navigation intercepts link clicks and form posts, fetches the new page and patches the DOM, so the site feels like a single-page app.

[StreamRendering] sends the page shell immediately, then streams the content when async work finishes.

Forms work with standard posts: give EditForm a FormName and bind the model with [SupplyParameterFromForm].

Code example: A streamed product page#

Razor / MarkupComponents/Pages/Products.razor Illustrative
@page "/products"
@attribute [StreamRendering]
@inject IProductService Products


<h1>Products</h1>
@if (items is null)
{
    <p>Loading…</p>
}
else
{
    <ul>
        @foreach (var p in items)
        {
            <li>@p.Name — ₹@p.Price</li>
        }
    </ul>
}


@code {
    private List<Product>? items;
    protected override async Task OnInitializedAsync() => items = await Products.GetAllAsync();
}
Expected output
The browser first receives “Loading…”, then the product list replaces it in the same response once the data is ready.

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. No @rendermode, so the page is static SSR.
  2. [StreamRendering] flushes the initial HTML before OnInitializedAsync finishes.
  3. When the data arrives, Blazor streams the updated markup.
  4. The output is real HTML that search engines can index.

Real-world use case#

Product catalogues, blog posts and documentation pages — fast, indexable, and cheap to host because no per-user connection is held.

Common mistakes#

Adding @onclick handlers to static pages

They never fire. Use links and forms, or make that component interactive.

Making the whole app interactive by default

Only interactive parts need a render mode. Keep content pages static.

Best practices#

  • Default to static SSR for content
  • Use [StreamRendering] for slow queries
  • Add interactivity only to components that need it
  • Use SSR forms with FormName for simple submissions

Remember this#

Static SSR = HTML per request, no circuit.

[StreamRendering] = shell now, data later.

Events need an interactive render mode.

Practice exercise#

Your task: What attribute lets a static page show “Loading…” before the data is ready?

Show solution
Razor / Markup Illustrative
@attribute [StreamRendering]

Mini quiz#

Blazor Server-Side Rendering quizTrue or false Question 1 of 1

Static SSR pages keep a SignalR connection open for each user.

Score so far: 0/0

Want more? Practise all Blazor MCQs · Blazor interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.