Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

What each render mode adds

You choose a render mode for each page, and each one costs something to build and to run. A static page is four pieces in one project. The same page in the browser is seven pieces in two. Count them before you make a page interactive.

One page, four render modes

The page is the customer list from Data access by render mode. It asks an interface, ICustomerStore, for its rows and shows them in a Table. The page's markup is the same in every render mode. What changes is what you write around it:

Render modeWhat you writeProjectsWhile the page is open
Static4 pieces: the page, the interface, a store, one registration1Nothing runs. Each click is a request.
Interactive ServerThe same 4, and one line on the page1A circuit on the server
WebAssembly7 pieces: those 4, a client store, endpoints, a second registration2The .NET runtime in the browser, calling your API
AutoThe same 72A circuit on the first visit, the browser's runtime after that

Static: four pieces

  • Customers.razor, the page.
  • ICustomerStore and its row type, CustomerRow.
  • EfCustomerStore, which reads your DbContext.
  • One line in Program.cs that registers the store.

The table still sorts, filters and pages, through the URL, and a form on the page still validates and saves, through a form post. See Data access on the server for the store. izzy add crud writes these pieces for a model you name.

Interactive Server: one line more

Customers.razor
@page "/customers"
@rendermode InteractiveServer
@inject ICustomerStore Customers

The four pieces stay as they are. The store already opens a context for each call, which a circuit needs. The cost is at run time: the server holds each open page in memory and stays connected to it. An app on several servers must send each user back to the same one, and a dropped connection needs session recovery.

WebAssembly and Auto: seven pieces in two projects

The browser can't reach your database, so the page's data crosses an API. The page and the interface move to the .Client project, and three pieces are new:

  • Customers.razor, moved to .Client, with its render mode.
  • ICustomerStore and CustomerRow, moved to .Client so both projects see them.
  • EfCustomerStore, unchanged, on the server. The page prerenders there, and an Auto page runs there on the first visit.
  • The server's registration, unchanged.
  • New: HttpCustomerStore, in .Client, which calls your API.
  • New: the endpoints it calls, which repeat the page's authorization. A user can call them without your page.
  • New: the client's registration, with its HttpClient.

Auto adds nothing to this list and removes nothing: the page runs in both places, so it needs both stores. An app with sign-in also registers the user's state in both projects. See Data access in the browser and Sign-in across render modes.

Add them in this order

  • Start static. IzzyBlazor's components respond in the browser on a static page: dialogs and menus open, tabs switch, tables sort and filter, forms validate and save. Most pages need no more.
  • Give one component a render mode when one part of a page needs C# between requests, such as a feed that updates by itself. The rest of the page stays static. See Interactive parts on static pages.
  • Make the page Interactive Server when most of it does. It costs one line.
  • Move the page to the browser when it should run without a circuit, or answer each click without a trip to the server. Add the three new pieces for the data that page uses, not for the whole app.

Each step leaves the page's markup alone, because the page asks the interface and never the database.

Next steps

  • Render modes: what each render mode is, and what components do in each.
  • Create an app: the starter's option for each render mode.

Connection lost

Rejoining the server…