Natrix.Ssr
0.19.0
dotnet add package Natrix.Ssr --version 0.19.0
NuGet\Install-Package Natrix.Ssr -Version 0.19.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Natrix.Ssr" Version="0.19.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Natrix.Ssr" Version="0.19.0" />
<PackageReference Include="Natrix.Ssr" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Natrix.Ssr --version 0.19.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Natrix.Ssr, 0.19.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Natrix.Ssr@0.19.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Natrix.Ssr&version=0.19.0
#tool nuget:?package=Natrix.Ssr&version=0.19.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Natrix.Ssr
Server-side rendering helpers for Natrix applications hosted on ASP.NET Core.
Features
SsrEventLoopruns a request the way the browser runs the app: one single-threaded event loop per request. Wrap the whole request handler inSsrEventLoop.RunAsync— mount, waiting for prefetches, and writing the response. Continuations run one at a time on it, which is what keeps the lock-free signals safe while prefetches run concurrently on the network.ServerPrefetchFeaturestarts every prefetch components register duringSetupand waits for all of them, cascades included. Construct it withHttpContext.RequestAbortedso an aborted request cancels its fetches.MainScriptcomponent that resolves the fingerprinted_framework/dotnet.jsstatic asset route from endpoint metadata.
Usage
Reference Natrix.Ssr from your server project and use components from Natrix.Ssr.Components.
app.MapFallback(httpContext => SsrEventLoop.RunAsync(async () =>
{
var root = new SsrRenderRoot();
var prefetch = new ServerPrefetchFeature(httpContext.RequestAborted);
using var _ = new NatrixHostBuilder()
.UseRootRenderer(root)
.SetFeature<IServerPrefetchFeature>(prefetch)
.UseRootComponent(() => new AppPage())
.Build()
.Mount();
await prefetch.WaitForCompletionAsync();
httpContext.Response.Headers.ContentType = "text/html";
await root.WriteAsync(httpContext.Response.BodyWriter, cancellationToken: httpContext.RequestAborted);
}));
The same rule as in the browser applies inside the loop: never block synchronously on a task whose continuation has to come back through it.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Natrix.Dom (>= 0.19.0)
-
net9.0
- Natrix.Dom (>= 0.19.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.