Skip to content

ui-router-server / ssr / settle

Function: settle() ​

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

Defined in: ssr.ts:76

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 starts the router, which happens once per router (start() on a UIRouterLit, urlService.listen() on a core 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
options?SettleOptionshow long to wait, and how many url rewrites to follow

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`

Throws ​

an Error when url rules rewrite the url more than `maxRewrites` times

Example ​

ts
import { installServerLocation } from 'ui-router-server/location';
import { settle } from 'ui-router-server/ssr';

installServerLocation(router, { urlConfig: { strict: false } });

for (const path of ['/', '/sheet/7B']) {
  await settle(router, path);
  pages.set(path, render(router));
}