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

# Function: withBase()

```ts
function withBase(base, path): string;
```

Defined in: [base-path.ts:37](https://github.com/simshanith/lit-ui-router/blob/1a559af0dc04d61d71ea4536fe2398902475b4ce/packages/ui-router-server/src/base-path.ts#L37)

A host-absolute path as a host serving the site under `base` spells it:
`withBase('/solar/', '/contacts')` is `/solar/contacts`.

`base` is a path base, with or without its trailing slash. Under `/` the
path stays as written, as does anything that is not a host-absolute path: a full url
(`https://example.test/x`), a protocol-relative one (`//example.test/x`)
and a relative path (`x`, `./x`, `?q=1`). The path is never inspected for
the base, so one that already carries it gets it twice.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `base` | `string` |
| `path` | `string` |

## Returns

`string`
