Skip to content

lit-ui-router-ssr / settle

Function: settle() ​

ts
function settle(
   router, 
   path, 
   options?
): Promise<Transition>;

Defined in: packages/lit-ui-router-ssr/src/settle.ts:60

Moves router to path and resolves once the transition the url starts has landed, resolves included, so a synchronous render reads the router after it.

It never calls router.start(), which runs once per router: it sets the url and syncs the router to it, whether or not the router is listening. A page loop calls it once per path on the same router. A redirectTo chain settles on its final state, and a path the router already stands on resolves with the transition that brought it there.

A failed transition still reaches stateService.defaultErrorHandler, which logs it unless replaced.

Parameters ​

ParameterTypeDescription
routerUIRouterthe server router, its location installed with installServerLocation
pathstringthe url to settle on, relative to the mount, query included
optionsSettleOptionshow long to wait

Returns ​

Promise<Transition>

the transition that landed

Throws ​

an Error when no url rule matches path and the router declares no otherwise

Throws ​

an Error whose cause is the transition's Rejection when it fails, a failed resolve's error in that rejection's detail

Throws ​

an Error when nothing lands within `timeout`

Example ​

ts
import { prerender, settle } from 'lit-ui-router-ssr';

await prerender({
  mounts,
  router,
  outDir: 'dist',
  paths: ['/', '/sheet/7B'],
  renderShell: async (verdict, { path }) => {
    await settle(router, path);
    return page();
  },
});