---
url: >-
  https://lit-ui-router.dev/reference/lit-ui-router-ssr/index/variables/redirectedTo.md
---
[lit-ui-router-ssr](../../index.md) / [lit-ui-router-ssr](../index.md) / redirectedTo

# Variable: redirectedTo

```ts
const redirectedTo: (router, transition) => SettledRedirect | undefined;
```

Defined in: packages/ui-router-server/dist/ssr.d.ts:140

Reports where `transition` was redirected to, so a host answers the
request with a redirect instead of the page it landed on. A transition is
redirected when a `redirectTo`, data or function, or a hook returning a
target state moved it, a change of params alone included. The status is
the `redirectStatusCode` of the state the redirect chain started from, the
state the url matched.

A url rule that rewrites the url (`when('/old', '/new')`) starts a fresh
transition rather than redirecting one, so it reports nothing: the
verdict answers a mount's pattern rules before render. A redirect with
`location: false` leaves the url where it was and reports nothing either.

Call it with the transition `settle` resolved. On a router that serves
more than one path, `settle` on the path the router already stands on
resolves with the transition that brought it there, which may be an
earlier path's redirect.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `router` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) | the router `transition` ran on, read for the url it landed on |
| `transition` | `Transition` | the transition `settle` resolved with |

## Returns

[`SettledRedirect`](../interfaces/SettledRedirect.md) | `undefined`

the landed url and status, or `undefined` when nothing redirected it

## Example

```ts
import type { UIRouter } from '@uirouter/core';
import { redirectedTo, settle } from 'ui-router-server/ssr';

// `router` serves the mount at /releases; `subpath` is the request's path within it.
async function serveRedirect(router: UIRouter, subpath: string) {
  const redirect = redirectedTo(router, await settle(router, subpath));

  if (redirect)
    return new Response(null, {
      status: redirect.status,
      headers: { Location: `/releases${redirect.url}` },
    });
}
```
