---
url: >-
  https://lit-ui-router.dev/reference/ui-router-server/redirects/functions/compileRoutes.md
---
[ui-router-server](../../index.md) / [redirects](../index.md) / compileRoutes

# Function: compileRoutes()

```ts
function compileRoutes(routes, config?): CompiledRoute[];
```

Defined in: [redirects.ts:193](https://github.com/simshanith/lit-ui-router/blob/6e47ef8d8a4b24e99c074fb5c8c9cfaddfdb36a4/packages/ui-router-server/src/redirects.ts#L193)

Compiles the url-addressable routes of a declaration set: each state's url
appended to its ancestors' (a state's parent is its `parent`, else its
dotted prefix, as in ui-router), params merged rootward. Url-less states
contribute nothing and match nothing, as in ui-router.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `routes` | readonly [`RouteDeclaration`](../interfaces/RouteDeclaration.md)\[] |
| `config?` | [`UrlMatcherCompilerConfig`](../../matcher/interfaces/UrlMatcherCompilerConfig.md) |

## Returns

[`CompiledRoute`](../interfaces/CompiledRoute.md)\[]
