RouteHandlerViewResponse

A RouteHandlerViewResponse can be a ViewDefinitionResponse object or a ViewResponse object.

ViewDefinitionResponse

Use this object to customize response input handled by the LWR server.

interface ViewDefinitionResponse {
  status?: number;
  view: RouteHandlerView;
  viewParams: Record<string, Json>
  renderOptions?: RenderOptions;
  cache?: CacheResponse;
  headers?: Record<string, string>
}
Property Type Required/Optional Description
status Number Optional The HTTP response status code.
view RouteHandlerView Required A partial route.
viewParams Record<string, Json> Required The record is passed into the templates as dynamic content.
renderOptions RenderOptions Optional Configure settings for metadata collection, embedded asset URLs, and caching the page view response.
cache CacheResponse Optional Page caching settings.
headers Record<string, string> Optional HTTP headers.

RenderOptions

interface RenderOptions {
    skipMetadataCollection?: boolean;
    freezeAssets?: boolean;
    skipCaching?: boolean;
}
Property Type Required/Optional Description
skipMetadataCollection Boolean Optional To skip parsing of body for <link> and <img> tags, set to true. The default value is false.
freezeAssets Boolean Optional To construct immutable URLs for embedded assets, set this value to true. The default value is set to runtimeEnvironment.immutableAssets.
skipCaching Boolean Optional To not cache the page view response, set this value to true. The default value is false.

CacheResponse

interface CacheResponse {
    ttl?: string | number;
}
Property Type Required/Optional Description
ttl String/Number Optional Set the "max-age" for the "Cache-Control" header.

ViewResponse

Use this object to return a completely custom response override.

interface ViewResponse {
    status?: number;
    body: Buffer | string | boolean | Json;
    cache?: CacheResponse;
    headers?: Record<string, string>;
}
Property Type Required/Optional Description
status Number Optional The HTTP response status code.
body Buffer/string/boolean/json Required The response body.
cache CacheResponse Optional Page caching settings.
headers Record<string, string> Optional HTTP headers.

See Also