Configuration

InertiaOptions, Vite, SSR, props, state and the middleware and result API.

All configuration is passed to AddInertia. Options marked “Development only” do nothing in other environments.

AddInertia(o => ...): InertiaOptions

OptionDefaultDescription
RootView"app.html"Root template relative to the content root (a Razor view name with UseRazorRootView). Paths outside the content root are refused.
RootElementId"app"Id of the root element and the data-page script.
VersionnullAsset version. null means the Vite manifest hash, or "" without one.
VersionResolvernullFunc<HttpContext, string?> per-request version; wins over Version when non-null.
EncryptHistoryfalseEncrypt browser history state of every page.
WithAllErrorsfalseSend every validation message per field instead of the first.
PreserveBigIntegersfalseEmit integers beyond ±(2^53−1) as {"$bigint":"..."}.
ExposeSharedPropKeystrueList top-level shared keys in sharedProps.
CspNoncenullFunc<HttpContext, string?>: the request's CSP nonce.
ConvertExternalRedirectstrueTurn an Inertia redirect to another origin into 409 + X-Inertia-Location.
UrlResolvernullFunc<HttpContext, string>: the page url.
Pages.Directory / Pages.Extensionsnull / .tsx .jsx .ts .js .vue .svelteDevelopment check that a rendered component has a page file.
TypeScript.OutputPath, .Page<T>(component), .SharedProps<T>(), .FlashData<T>()nullTypeScript declarations, written in Development.
Share(key, value) / Share(key, Func<HttpContext, object?>)noneShared props.

o.Vite: ViteOptions

OptionDefaultDescription
PublicDirectory"wwwroot"Web root containing the build directory and hot file.
BuildDirectory"build"Vite output directory under PublicDirectory; also the URL prefix.
ManifestPathnullManifest path relative to the content root. null = {PublicDirectory}/{BuildDirectory}/.vite/manifest.json, then manifest.json.
HotFilePathnullHot file relative to the content root. null = {PublicDirectory}/hot. Read in Development only.
DevServerUrlnullDev server origin, e.g. http://localhost:5173. When set, dev tags always render.
AssetBaseUrlnullReplaces {PathBase}/{BuildDirectory} as the URL prefix of built assets.
PrefetchNoneWaterfall or Aggressive: prefetch code-split chunks after load.
PrefetchConcurrency3Chunks Waterfall downloads at a time.

o.Ssr: SsrOptions

OptionDefaultDescription
ModeDisabledDisabled, Preferred or Required. Disabled cannot be overridden per response.
Urlsempty (http://127.0.0.1:13714)SSR server base URLs. Not used with UseNodeProcess().
Timeout5 sTotal deadline per render. Timeout.InfiniteTimeSpan disables it.
MaxResponseBytes16 MiBLimit on actual response bytes, including errors and chunked responses.
MaxPageBytes2 MiBPages whose JSON is larger render on the client without a call.
BundlePathnullSkip SSR while this file is missing, unless the Vite dev server runs.
ExcludePathsemptyRequest paths never rendered on the server (exact, or a trailing * for a prefix).
Concurrency.MaxActive8Renders in flight per server from this app instance; 0 for no limit.
Concurrency.MaxQueued32Renders waiting for a slot per server.
Concurrency.QueueTimeout250 msHow long a render waits for a slot.
CircuitBreaker.EnabledtruePause servers that keep failing.
CircuitBreaker.FailureThreshold5Consecutive failures that open a server's circuit.
CircuitBreaker.BreakDuration10 sHow long an open circuit skips the server before one probe.
Cache.DurationZero (off)Reuse a render for this long when the page JSON is the same.
Cache.StaleForZeroServe stale while re-rendering.
Cache.MaxBytes64 MiBSize of the default store's render cache.
UseNodeProcess(configure?)offStart and supervise Node SSR processes (sets Mode = Preferred when Disabled).

Per response: Render(...).WithSsr(SsrMode) and .WithoutSsr(). The full SSR options are in Server-side rendering.

o.Props: InertiaPropsOptions

OptionDefaultDescription
MaxConcurrency4Loaders marked .Parallel() that run at once per render. Must be positive.

o.State: InertiaStateOptions

OptionDefaultDescription
CookieName".Inertia.State"Cookie name (cookie store) or session key (session store).
CookieSecurePolicySameAsRequestWhen the state cookie is Secure.
UseSession()offUse ISession instead of the encrypted cookie.
AddInertiaMvc(o => o.UseTempDataStateStore())offUse MVC TempData. Inertia.Net.Mvc package.

Middleware and endpoint API

APIDescription
services.AddInertia(configure?)Registers services and options.
app.UseInertia()The protocol middleware. Before the endpoints; after UseSession() when used.
app.UseInertiaAntiforgery(configure?)Issues the XSRF-TOKEN cookie and validates unsafe requests (419 on failure).
app.MapInertia(pattern, component, props?)GET and HEAD endpoint that renders the component.
services.AddInertiaDevTools(configure?) / app.MapInertiaDevTools()DevTools recorder and read API.
app.UseInertiaAntiforgeryCookie(cookieName = "XSRF-TOKEN")Only writes the token cookie; validation is up to you.
endpoint.WithInertiaValidation()Minimal API: validation failures redirect back with errors.
endpoint.WithInertiaPrecognition()Minimal API: WithInertiaValidation() plus Precognition.
healthChecks.AddInertiaSsr(...)SSR health check from the gateway's state.
mvc.AddInertiaMvc(o => o.UseRazorRootView("App"))MVC filter, optional Razor root view and component resolver.
config.UseInertia(configure?)FastEndpoints: validation redirect and Precognition.
Render(component, props?)InertiaResult: .WithStatusCode, .WithRootView, .WithViewData, .WithSsr, .WithoutSsr, .WithSsrCache.
Location(url)InertiaLocationResult.
Back(fallback = "~/")InertiaBackResult: .WithErrors, .WithFlash.
httpContext.Inertia()InertiaFeature: Share, Flash, WithErrors, ClearHistory, EncryptHistory, PreserveFragment.
Send.InertiaAsync(...), Send.InertiaLocationAsync(...), Send.InertiaBackAsync(...)FastEndpoints Send extensions.

Extension points

IInertiaRootView, IInertiaStateStore, ViteAssets, InertiaRequest (parsed headers), InertiaHeaders (header name constants), InertiaSsrException, InertiaSsr.HttpClientName (the SSR HTTP client) and InertiaDiagnostics (meter and activity source names).