---
schema_version: "1"
id: 7f30956aec414952f6d50ee030a5ac496336f912fff65e9e07ab91c7ad376b91
title: RouteHandlerViewResponse
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwr-node/lwr/references/ss-routing-reference/routehandlerviewresponse.md
canonical_url: https://developer.salesforce.com/docs/platform/lwr/references/ss-routing-reference/routehandlerviewresponse.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 29ba7704249f4058d86b7d7f7923f28c0be75ae6c6f328bec9522d60e331dc32
products:
  - Lightning Web Runtime
---
# RouteHandlerViewResponse

A `RouteHandlerViewResponse` can be a [`ViewDefinitionResponse`](#viewdefinitionresponse) object or a [`ViewResponse`](#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](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status).           |
| `view`          | [`RouteHandlerView`](https://developer.salesforce.com/docs/platform/lwr/references/ss-routing-reference/routehandlerfunction.md#routehandlerview) | Required          | A partial route.                                                                                     |
| `viewParams`    | `Record<string, Json>`                                         | Required          | The record is passed into the templates as dynamic content.                                          |
| `renderOptions` | [`RenderOptions`](#renderoptions)                              | Optional          | Configure settings for metadata collection, embedded asset URLs, and caching the page view response. |
| `cache`         | [`CacheResponse`](#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](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status). |
| `body`    | `Buffer`/`string`/`boolean`/`json` | Required          | The response body.                                                                         |
| `cache`   | [`CacheResponse`](#cacheresponse)  | Optional          | Page caching settings.                                                                     |
| `headers` | `Record<string, string>`           | Optional          | HTTP headers.                                                                              |

**See Also**

- [Server-Side Routing: Route Handler Functions](https://developer.salesforce.com/docs/platform/lwr/guide/lwr-routing-server.html#route-handler-functions)
