Skip to content

lit-ui-router-ssr / adoptUiViewContext

Variable: adoptUiViewContext ​

ts
const adoptUiViewContext: AdoptUiViewContext;

Defined in: packages/lit-ui-router-ssr/src/adopt-context.ts:64

The context key a hydration client answers for, under the container it hydrates, with the function that adopts a waking <ui-view>'s held nodes.

The view requests it once on its waking update, after re-seeking its router, and calls what it gets. Unanswered, the view drops the held nodes and warns.

hydrateRoot provides it with core's provideContext(); an element provides it with @provide from @lit/context, since the key is the one createContext() would have produced.

Example ​

ts
import { provideContext } from 'lit-ui-router/context';
import { adoptUiViewContext } from 'lit-ui-router-ssr/client';

const uninstall = provideContext(container, adoptUiViewContext, (view) =>
  adopt(view),
);