Namespace: ReactDotNetCore.
// Strongly typed (TComponent : IReactComponent). Component name = type name.
ReactDotNetCoreResult ReactView<TComponent>(this ControllerBase controller, object? model = null)
// String based.
ReactDotNetCoreResult ReactView(this ControllerBase controller, string component, object? model = null)Empty marker interface. Implement it with a type named after a view to enable ReactView<T>():
public sealed class Dashboard : IReactComponent;| Member | Type | Notes |
|---|---|---|
Component |
string |
The view/component name. |
Model |
object? |
The model serialized to props. |
Title |
string? |
Optional <title>; defaults to the component name. |
IServiceCollection AddReactDotNetCore(
this IServiceCollection services,
Action<ReactDotNetCoreOptions>? configure = null)Registers options, the manifest provider, the renderer, the typed SSR client, and (unless
LaunchSidecar = false) the sidecar hosted service. Auto-selects a free port when SidecarPort = 0.
See Configuration for the full table. Key members: SidecarPort,
RenderTimeout, MaxSidecarRestarts, DevMode, PublicBasePath, ClientManifest, JsonOptions.
| Type | Use |
|---|---|
ReactDotNetCoreRenderer |
RenderPageAsync(component, model, title, ct) → full HTML string. |
ReactSsrClient |
RenderAsync(component, propsJson, ct), WaitForReadyAsync(timeout, ct). |
ViteManifestProvider |
ResolveEntry(entryKey?) → { File, Css[] }. |
ESM, with subpath exports.
function createRegistry(modules: GlobModules): ComponentRegistry
function registeredNames(registry: ComponentRegistry): string[]
const ROOT_ID: "react-dotnetcore-root"
const PROPS_ID: "react-dotnetcore-props"
const COMPONENT_ATTR: "reactDotnetcoreComponent"
type ComponentRegistry = Record<string, React.ComponentType<any>>
type GlobModules = Record<string, { default?: React.ComponentType<any> }>createRegistry takes a Vite import.meta.glob(..., { eager: true }) result and keys components by
file base name.
type ServerRenderer = (component: string, props: unknown) => string
function createServerRenderer(registry: ComponentRegistry): ServerRendererReturns the render(component, props) used by entry-server.tsx. Throws (with the list of known
components) if a name isn't registered.
interface MountOptions { rootId?: string; propsId?: string }
function mount(registry: ComponentRegistry, opts?: MountOptions): void
function readProps(propsId?: string): unknownmount reads the root element, parses embedded props, and calls hydrateRoot. No-ops if the root is
absent.
function startFromEnv(): Promise<void> // reads REACTDOTNETCORE_* env vars; used by ssr-server.mjs
function createSsrServer(opts: SsrServerOptions): http.Server // production sidecar
function createDevServer(opts: DevServerOptions): Promise<{ httpServer, vite }> // Vite HMR sidecar
interface SsrServerOptions { render: ServerRenderer; port: number; host?: string;
maxBodyBytes?: number; onListen?: (port: number) => void }
interface DevServerOptions { root: string; port: number; host?: string;
serverEntry?: string; onListen?: (port: number) => void }react-dotnetcore-ssr — runs startFromEnv(). Equivalent to the two-line ssr-server.mjs. Same
environment contract.
| Method | Path | Body | Response |
|---|---|---|---|
GET |
/health |
— | 200 ok |
POST |
/render |
{ component, props } |
{ html } or { error } |