Skip to content

lit-ui-router / provideRouter

Variable: provideRouter ​

ts
const provideRouter: (root, router) => () => void;

Defined in: packages/lit-ui-router/src/context.ts:409

provideContext bound to routerContext: the element-free twin of <ui-router>, answering router requests that reach root.

The parameter is UIRouterLit, not UIRouter, because the key this answers is branded with UIRouterLit, and a provider may only answer with the value its key promises. The slot (`withRouterSync`) takes either.

Parameters ​

ParameterTypeDescription
rootEventTargetthe event target requests travel to
routerUIRouterLitthe router to answer with

Returns ​

a function that uninstalls this provider

() => void

Example ​

ts
import { provideRouter } from 'lit-ui-router/context';

const uninstall = provideRouter(globalThis.litServerRoot, router);
try {
  // …render…
} finally {
  uninstall();
}

See ​

withRouterSync for the slot the same render sets instead