Skip to content

lit-ui-router / SrefHrefDirective

Class: SrefHrefDirective

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

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:53
optionsTransitionOptions{}the transition options from the last renderpackages/lit-ui-router/src/sref-href.ts:42
paramsRawParams{}the target state params from the last renderpackages/lit-ui-router/src/sref-href.ts:40
statestring | nullnullthe target state name from the last renderpackages/lit-ui-router/src/sref-href.ts:38
targetState| TargetState | nullnullthe resolved target, or null until the router is foundpackages/lit-ui-router/src/sref-href.ts:55

Methods

render()

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

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

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 noChange | typeof nothing

Overrides

ts
AsyncDirective.render