Table of Contents

Class NiteExtensions

Namespace
Nite
Assembly
Nite.dll
public static class NiteExtensions
Inheritance
NiteExtensions
Inherited Members

Methods

AddNite(IServiceCollection, Action<NiteOptions>?)

Registers Nite's services and tag helper dependencies.

public static IServiceCollection AddNite(this IServiceCollection services, Action<NiteOptions>? configure = null)

Parameters

services IServiceCollection
configure Action<NiteOptions>

Returns

IServiceCollection

MapNiteSpa(IEndpointRouteBuilder, string, string?, string?)

Serves an HTML entry from the client root (default index.html) for / and, as a fallback, for any other path without a file extension, so client-side routes survive a refresh. Real endpoints always win. Requests under apiPrefix never fall back, so a mistyped API call gets a 404 instead of a page of HTML.

public static IEndpointConventionBuilder MapNiteSpa(this IEndpointRouteBuilder endpoints, string page = "index.html", string? apiPrefix = "/api", string? path = null)

Parameters

endpoints IEndpointRouteBuilder
page string
apiPrefix string
path string

Serve the page only under this path: "/login" answers /login and /login/…. An app can map several single-page apps this way, plus one without a path for everything else; the more specific path wins.

Returns

IEndpointConventionBuilder

Remarks

In development the page is read from source on every request with the dev client injected; in production it is the built copy from wwwroot/_nite.

UseNite(IApplicationBuilder)

In development, serves compiled modules, dependencies and the HMR socket under /_nite. In production this does nothing: the build output is ordinary static files in wwwroot/_nite. Call it before UseRouting/MapStaticAssets.

public static IApplicationBuilder UseNite(this IApplicationBuilder app)

Parameters

app IApplicationBuilder

Returns

IApplicationBuilder