---
url: https://lit-ui-router.dev/api/reference/components/UIRouterLitElement.md
---
[lit-ui-router](../index.md) / UIRouterLitElement

# Class: UIRouterLitElement

Defined in: [packages/lit-ui-router/src/ui-router.ts:47](https://github.com/simshanith/lit-ui-router/blob/92660184d9980e90964f7e785d5efeb5cae43b42/packages/lit-ui-router/src/ui-router.ts#L47)

## Slots

* default — \<ui-router> renders slotted content.

## Events

* ui-router-context — \<ui-router> listens to the ui-router-context event and provides the uiRouter instance. It answers the community context-request protocol for {@link routerContext} from the same listener position, so an element built on @lit/context gets the router too. The two paths coexist and neither sees the other's event: {@link UIRouterLitElement.seekRouter} asks on ui-router-context first and falls back to {@link requestRouter}. The ui-router-context event is deprecated in favour of context-request.

## Extends

* [`LitElement`](https://lit.dev/docs/api/LitElement/)

## Properties

| Property | Type | Description | Defined in |
| ------ | ------ | ------ | ------ |
|  `uiRouter` | [`UIRouterLit`](../core/UIRouterLit.md) | `undefined` | Root uiRouter singleton. If not provided, the element creates and assigns a new instance. | [packages/lit-ui-router/src/ui-router.ts:53](https://github.com/simshanith/lit-ui-router/blob/92660184d9980e90964f7e785d5efeb5cae43b42/packages/lit-ui-router/src/ui-router.ts#L53) |

## Methods

### ~~seekRouter()~~

```ts
static seekRouter(candidate): UIRouterLit | undefined;
```

Defined in: [packages/lit-ui-router/src/ui-router.ts:100](https://github.com/simshanith/lit-ui-router/blob/92660184d9980e90964f7e785d5efeb5cae43b42/packages/lit-ui-router/src/ui-router.ts#L100)

Discovers the [UIRouterLit](../core/UIRouterLit.md) instance provided by the nearest
enclosing \<ui-router> element.

Dispatches a bubbling, composed ui-router-context event from
the candidate element; the enclosing \<ui-router>
answers it with its router instance. Returns undefined when
the candidate is not inside a \<ui-router> (e.g. not
yet connected).

This is the dependency-injection primitive for integrating external
reactivity systems (state stores, controllers) with the router context —
call it from hostConnected() / connectedCallback()
instead of prop-drilling the router instance.

When no \<ui-router> answers, it asks again with
[requestRouter](../core/requestRouter.md), so an ancestor providing [routerContext](../core/routerContext.md)
over the community protocol — a bare @lit/context
ContextProvider, say — is found as well.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `candidate` | `Element` |

#### Returns

[`UIRouterLit`](../core/UIRouterLit.md) | `undefined`

#### Deprecated

Use the `context-request` protocol instead: `requestRouter` or `routerContext` from `lit-ui-router/context`.
