Skip to content

lit-ui-router / SrefHrefDirective

Class: SrefHrefDirective ​

Defined in: packages/lit-ui-router/src/sref-href.ts:37

The attribute-part sibling of UiSrefDirective: the same link, bound where the href lives instead of on the element.

render() is a function of the router and the arguments alone — it returns the href and touches no DOM — which is the shape a server renderer needs, since it runs render() and never update(). It finds its router from the element in a document and from the server's render-scoped router under @lit-labs/ssr. Everything else that needs the element (the click handler, the target event for an enclosing uiSrefActive) lives in update(), which only a live document runs.

See ​

srefHref for the public API

Extends ​

Properties ​

PropertyTypeDefault valueDescriptionDefined in
hrefstring | nullnullthe href computed for the target, or null when there is nonepackages/lit-ui-router/src/sref-href.ts:54
optionsTransitionOptions{}the transition options from the last renderpackages/lit-ui-router/src/sref-href.ts:43
paramsRawParams{}the target state params from the last renderpackages/lit-ui-router/src/sref-href.ts:41
statestring | nullnullthe target state name from the last renderpackages/lit-ui-router/src/sref-href.ts:39
targetState| TargetState | nullnullthe resolved target, or null until the router is foundpackages/lit-ui-router/src/sref-href.ts:56

Methods ​

render() ​

ts
render(
   state, 
   params?, 
   options?
): string | typeof nothing | typeof noChange;

Defined in: packages/lit-ui-router/src/sref-href.ts:95

The href for the target state; nothing when the state has no url; noChange until a router is found, so an attribute a server wrote survives hydration untouched.

The scoped slot is read per render rather than cached: a server directive instance renders once, and a client one never finds a scoped router.

Parameters ​

ParameterType
statestring
params?RawParams
options?TransitionOptions

Returns ​

string | typeof nothing | typeof noChange

Overrides ​

ts
AsyncDirective.render