---
schema_version: "1"
id: b09fac8843177d6f935536d8f5cb82ff8213e0de858ca9bc1b8e15b38334299c
title: LwrConfigRouteDefinition
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwr-node/lwr/references/csr-reference/lwrconfigroutedefinition.md
canonical_url: https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/lwrconfigroutedefinition.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0be2011c08f1825090f2b9a561a6d428460223816989e8f2b36f8c1de6088440
products:
  - Lightning Web Runtime
---
# LwrConfigRouteDefinition

**important:** To configure a router module with the [Router Module Provider](https://developer.salesforce.com/docs/platform/lwr/guide/lwr-create-router.html#router-module-provider), you have to set up both [`LwrRouterConfig`](https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/lwrrouterconfig.md) and `LwrConfigRouteDefinition`.

## Syntax

```
interface LwrConfigRouteDefinition<TMetadata = Record<string, any>> {
    id: string;
    uri: string;
    page: Partial<PageReference>
    patterns?: { [paramName: string]: string };
    exact?: boolean;
    metadata?: TMetadata;
    // LwrConfigRouteDefinition must have ONE of the following, not both
    handler?: string; // a STRING reference to the handler class
    component?: string; // a STRING reference to a page component
}
```

## Properties

`LwrConfigRouteDefinition` object contains similar properties as the [`RouteDefinition`](https://developer.salesforce.com/docs/platform/lwr/references/csr-reference/routedefinition.md) object. `handler` and `component` are string references, as LwrConfigRouteDefinition is pure JSON and can't contain any functions. Only define either the `handler` or `component` property, **not both**.

| Property    | Type    | Required/Optional | Description                                                                                                                                                                                                                                                                                                                                                                                                      |
| ----------- | ------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`        | String  | Optional          | Each `LwrConfigRouteDefinition` must have a unique `id` identifier.                                                                                                                                                                                                                                                                                                                                              |
| `uri`       | String  | Optional          | A pattern for URI locations that match the `LwrConfigRouteDefinition`. You can't use the `#` and `*` characters.                                                                                                                                                                                                                                                                                                 |
| `page`      |         | Required          | The form of page references that match the `LwrConfigRouteDefinition`. `page` values can be `:parameter` bindings, which map a path or query parameter from the URI to an `attributes` or `state` property, or literal bindings, which hard code a `type`, `attribute`, or `state` property to a literal value. Literal bindings can't contain the following characters: `?`, `*`, `#`, `&`, `+`, `;`, `(`, `)`. |
| `patterns`  |         | Optional          | A regular expression that a parameter has to match to be valid. To prevent unexpected values in the expression pattern, explicitly wrap the expression in the start-of-line character (`^`) and end-of-line character (`$`). For example: `{"patterns": {"parameter": "^id[0-9a-zA-Z]{5}$"}}`.                                                                                                                   |
| `exact`     | Boolean | Optional          | If there's a nested router, this value must be `false`. The default value is `true`.                                                                                                                                                                                                                                                                                                                             |
| `metadata`  |         | Optional          | Developer-defined metadata in the form of key (string) and value (any type) pairs. You can use the `metadata` property to attach additional information to an `LwrConfigRouteDefinition`. Extend `LwrConfigRouteDefinition` for required or more strongly typed metadata.                                                                                                                                        |
| `handler`   | String  | See description   | An `LwrConfigRouteDefinition` must contain a handler or a component, but not both. `handler` is a string reference to the `RouteHandler` class specifier.                                                                                                                                                                                                                                                        |
| `component` | String  | See description   | An `LwrConfigRouteDefinition` must contain a handler or a component, but not both. `component` is a string reference to the view component specifier. Use this property to directly specify the view component without authoring a route handler.                                                                                                                                                                |

## Example

```
{
    "id": "home",
    "uri": "/",
    "component": "examples/home",
    "page": {
        "type": "home"
    },
    "metadata": {
        "title": "Home"
    }
},
{
    "id": "namedPage",
    "uri": "/:pageName",
    "handler": "examples/namedPageHandler",
    "page": {
        "type": "namedPage",
        "attributes": {
            "pageName": ":pageName"
        }
    }
}
```

**See Also**

- [Routers and Route Matching: Route Definitions](https://developer.salesforce.com/docs/platform/lwr/guides/lwr-routers-route-matching.md#route-definitions)
- [Create a Router: Configure the Router JSON](https://developer.salesforce.com/docs/platform/lwr/guides/lwr-create-router.md#4-configure-the-router-json)
