routes

Each server-side routes object in an lwr.config.json file includes some of these properties

Properties

Property Type Required/Optional Description
id String Required The unique identifier for the route.
path String Required The unique URI path from which the route is served.
layoutTemplate String Optional The path to a static template that renders the page layout. If you don't set a value for layoutTemplate, it uses a default template.
contentTemplate Filepath See description Each route must have either a rootComponent or a contentTemplate, but not both. Set contentTemplate as the path to a static template that renders the page content.
rootComponent Filepath See description Each route must have either a rootComponent or a contentTemplate, but not both. Set rootComponent as the path to the top-level Lightning web component that LWR bootstraps into the HTML output for the route. If you use a rootComponent, LWR applies a default contentTemplate to render it.
properties JSON object Optional A JSON object that can be passed to the templates as context.
routeHandler String Required A path to a route handler function configured for the route.
cache Key-value pairs Optional The cache settings for the routing, including: <ul><li>ttl: A number, in seconds, or a time string to use as the max-age on the Cache-Control header.</li></ul>
bootstrap JSON object Optional The bootstrap object contains client options that determine how an application page is loaded, including: <ul><li>syntheticShadow: An optional boolean value. When true, LWC synthetic shadow is enabled. The default value is false.</li><li>services: An optional array of LWC modules to run on page load.</li><li>ssr: An optional boolean value. When true, server-side rendering is enabled for the route. The default value is false.</li><li>mixedMode: An optional boolean value. When true, mixed mode is enabled for the route. The default value is false.</li></ul>

Example

{
  "id": "example",
  "path": "/",
  "rootComponent": "example/app",
  "layoutTemplate": "$layoutsDir/main.html",
  "properties": { "staticParam": "This is the Home page" },
  "cache": { "ttl": 60 }
  "bootstrap": {
      "syntheticShadow": true,
      "services": ["example/service", "example/loaderHooks"]
  }
}