Render Modes

Events

Complex Static SSR + Server & WebAssembly islands

The same component in five islands. Islands share a hub only when they share a DI container, which is the boundary documented in the render modes tutorial.

How it works

Try it: increment and ping from each island. Wait for the WebAssembly islands to become interactive first.

  • A, B and E share a count and pings: every Interactive Server island on a page lives in the same circuit, so they resolve the same Scoped IRfEventHub.
  • C and D share with each other: all WebAssembly islands share one runtime and one DI container (the client Program.cs calls AddRForgeEvents too).
  • Server and WebAssembly islands never share. They're different DI containers. The library deliberately has no JS bridge.
  • E shows the cascade caveat. An EventScope declared in static markup doesn't reach an island inside it. Declare scopes inside interactive components.
  • The static reader at the top got a value from the request's own throwaway hub. Static and prerendered components read state but never subscribe.
Static component (no render mode): it renders once on the server and never becomes interactive.
It read IslandState.Count = 0 from this request's own hub while the HTML was generated. It never subscribed and never re-renders. Static output is a snapshot.

Interactive Server: one circuit, one hub

Server A

Server not interactive yet

Shared IslandState.Count: 0

Last ping received: none

Server B

Server not interactive yet

Shared IslandState.Count: 0

Last ping received: none

Server E (inside a static EventScope)

Server not interactive yet

Shared IslandState.Count: 0

Last ping received: none

Interactive WebAssembly: one runtime, one hub

WASM C

WebAssembly not interactive yet

Shared IslandState.Count: 0

Last ping received: none

WASM D

WebAssembly not interactive yet

Shared IslandState.Count: 0

Last ping received: none

An unhandled error has occurred. Reload 🗙