Outlets

An outlet dynamically renders view components. A view is the component to display when the application navigates to a location.

This process is naturally lazy: the view isn’t imported until the outlet consumes it, so any unused views aren’t fetched. When the router’s view state changes, the outlet is flagged to display the view. Then, if the view module hasn’t already been fetched, there may be an asynchronous process to retrieve it.

my/app/app.html
1<template>
2    <lwr-router-container>
3        <lwr-outlet refocus-off onviewchange={onViewChange} onviewerror={onViewError}>
4            <div slot="error">View component cannot display</div>
5        </lwr-outlet>
6    </lwr-router-container>
7</template>

A route handler module can return multiple views.

1import type { Module, RouteHandlerCallback } from "lwr/router";
2
3export default class HomeHandler {
4  callback: RouteHandlerCallback;
5
6  constructor(callback: RouteHandlerCallback) {
7    this.callback = callback;
8  }
9
10  dispose(): void {}
11
12  update(): void {
13    this.callback({
14      viewset: {
15        // return multiple views
16        default: (): Promise<Module> => import("my/home"),
17        nav: (): Promise<Module> => import("my/homeNav"),
18        footer: (): Promise<Module> => import("my/homeInfo"),
19      },
20    });
21  }
22}

You can use multiple outlets to display all the current view components by setting different view-name values:

my/app/app.html
1<template>
2  <lwr-router-container>
3    <lwr-outlet view-name="nav"></lwr-outlet>
4    <lwr-outlet><!-- default view --></lwr-outlet>
5    <lwr-outlet view-name="footer"></lwr-outlet>
6  </lwr-router-container>
7</template>

Lightning Navigation 

The @lwrjs/router package provides an implementation of lightning/navigation. The lightning/navigation module is an alias for the lwr/navigation module, so it includes the same wires and APIs, along with NavigationMixin. This allows you to write a component once and use it anywhere that supports the lightning/navigation contracts.

Developer Preview Feature

Feature is available as a developer preview. Feature is not generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All commands, parameters, and other features are subject to change or deprecation at any time, with or without notice. Do not implement functionality developed with these commands or tools.