---
url: https://lit-ui-router.dev/reference/ui-router-signals/classes/RouterSignals.md
---
[ui-router-signals](../index.md) / RouterSignals

# Class: RouterSignals

Defined in: [ui-router-signals/src/router-signals.ts:42](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L42)

A signal mirror of a router's current state.

A single `transitionService.onSuccess` hook (registered by
[attach](#attach)) writes one `RouteSnapshot` per
successful transition into a `Signal.State`. The public fields are
read-only `Signal.Computed`s over it, so any signal consumer — a
`watchSelection` callback, a framework binding such as
lit-ui-router-signals, or a `@lit-labs/signals` `SignalWatcher` render —
tracks exactly the fields it reads. `onSuccess` is the only hook a later transition cannot supersede, so
every value is a settled route. An `onStart` hook feeds the two fields
about the newest transition, [pending](#pending) and
[error](#error).

Use the [for](#for) factory to get the signals for a
router: it memoizes one instance (and its transition hooks) per router.

## Constructors

### Constructor

```ts
new RouterSignals(): RouterSignals;
```

#### Returns

`RouterSignals`

## Properties

| Property | Modifier | Type | Description | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `current` | `readonly` | [`Computed`](https://github.com/tc39/proposal-signals#the-signal-api)< | [`StateDeclaration`](https://ui-router.github.io/core/docs/latest/interfaces/_state_interface_.statedeclaration.html) | `undefined`> | The current state declaration (`globals.current`). | [ui-router-signals/src/router-signals.ts:59](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L59) |
|  `error` | `readonly` | [`Computed`](https://github.com/tc39/proposal-signals#the-signal-api)<`Rejection` | `undefined`> | The newest transition's failure, as core's `Rejection`: set only for a `RejectType.ERROR` rejection, such as a throwing resolve, and cleared when the next transition starts. Superseded, redirected, aborted and ignored transitions leave it `undefined`, as does a success. A failure changes `pending` and `error` together. Not part of [route](#route). | [ui-router-signals/src/router-signals.ts:88](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L88) |
|  `params` | `readonly` | [`Computed`](https://github.com/tc39/proposal-signals#the-signal-api)<[`RawParams`](https://ui-router.github.io/core/docs/latest/interfaces/_params_interface_.rawparams.html)> | The current parameter values (`globals.params`), replaced per transition. | [ui-router-signals/src/router-signals.ts:63](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L63) |
|  `pending` | `readonly` | [`Computed`](https://github.com/tc39/proposal-signals#the-signal-api)< | [`Transition`](https://ui-router.github.io/core/docs/latest/classes/_transition_transition_.transition.html) | `undefined`> | The newest transition still in flight; `undefined` when none is. A superseded transition never clears its successor, and an error or abort clears it like a success does. Not part of [route](#route): every snapshot is a settled route. | [ui-router-signals/src/router-signals.ts:77](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L77) |
|  `route` | `readonly` | [`Computed`](https://github.com/tc39/proposal-signals#the-signal-api)<[`RouteSnapshot`](../interfaces/RouteSnapshot.md)> | The whole route as one value, replaced per transition. Typed by [RouteTypes](../interfaces/RouteTypes.md) when a registry fills it in. | [ui-router-signals/src/router-signals.ts:54](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L54) |
|  `transition` | `readonly` | [`Computed`](https://github.com/tc39/proposal-signals#the-signal-api)< | [`Transition`](https://ui-router.github.io/core/docs/latest/classes/_transition_transition_.transition.html) | `undefined`> | The most recent successful transition. | [ui-router-signals/src/router-signals.ts:68](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L68) |

## Methods

### attach()

```ts
attach(router): () => void;
```

Defined in: [ui-router-signals/src/router-signals.ts:130](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L130)

Starts mirroring the given router. Called by
[for](#for); call directly only when managing the
instance yourself.

Idempotent per router: attaching again to the router already being
mirrored returns the same deregistration function instead of
registering the hooks again. Calling that function detaches, after which
the instance can be attached again.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `router` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) |

#### Returns

the hooks' deregistration function.

() => `void`

#### Throws

if already attached to a *different* router — one instance
mirrors one router; use [for](#for) to get that
router's own signals.

***

### for()

```ts
static for(router): RouterSignals;
```

Defined in: [ui-router-signals/src/router-signals.ts:103](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L103)

The signals for the given router — one instance per router. The first
call attaches the transition hooks; the hooks (and the instance) live as
long as the router itself.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `router` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) |

#### Returns

`RouterSignals`

***

### includes()

```ts
includes(stateOrName, params?): boolean;
```

Defined in: [ui-router-signals/src/router-signals.ts:166](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/router-signals.ts#L166)

Tracked `StateService.includes`, evaluated against the current
[route](#route): is the state (or glob pattern, e.g.
`'admin.**'`) included in the settled active state? Reading it inside a
computed or watcher subscribes to every transition.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `stateOrName` | [`StateOrName`](https://ui-router.github.io/core/docs/latest/modules/_state_interface_.html#stateorname) |
| `params?` | [`RawParams`](https://ui-router.github.io/core/docs/latest/interfaces/_params_interface_.rawparams.html) |

#### Returns

`boolean`
