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

# Function: format()

```ts
function format(matcher, values?): string | null;
```

Defined in: [url-matcher.ts:686](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-server/src/url-matcher.ts#L686)

Builds a url from a compiled matcher by substituting parameter values —
the inverse of [exec](exec.md), mirroring core's UrlMatcher.format for the
supported subset (no parent-matcher composition: matchers here never
append). Default values honor the squash policy, search params render
as a query string, and `values['#']` appends a hash fragment.

Returns null when any value fails its param's validation.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `matcher` | [`CompiledMatcher`](../interfaces/CompiledMatcher.md)<`unknown`> |
| `values?` | [`RawParams`](https://ui-router.github.io/core/docs/latest/interfaces/_params_interface_.rawparams.html) |

## Returns

`string` | `null`
