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

# Function: mergeSearch()

```ts
function mergeSearch(location, incoming): string;
```

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

Merges a request's search into a redirect `location` — the correct-by-
default replacement for `location + url.search`, which yields `?a=1?b=2`.
Params the redirect target declared win; remaining request params are
appended (all values of multi-value keys). Accepts the incoming search
with or without the leading '?'. Operates on `pathname?search#fragment`
strings as produced in redirect verdicts: a fragment (which
[format](../../matcher/functions/format.md) emits for a `'#'` param value) is detached
before the merge and re-appended after it, so the query keeps its place
ahead of the fragment.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `location` | `string` |
| `incoming` | `string` |

## Returns

`string`
