---
url: https://lit-ui-router.dev/reference/lit-ui-router/core/provideRouter.md
---
[lit-ui-router](../index.md) / provideRouter

# Variable: provideRouter

```ts
const provideRouter: (root, router) => () => void;
```

Defined in: [packages/lit-ui-router/src/context.ts:432](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/lit-ui-router/src/context.ts#L432)

[provideContext](provideContext.md) bound to [routerContext](routerContext.md): the element-free twin
of `<ui-router>`, answering router requests that reach `root`.

The parameter is `UIRouterLit`, not `UIRouter`, because the key this answers
is branded with `UIRouterLit`, and a provider may only answer with the value
its key promises. The slot ([\`withRouterSync\`](withRouterSync.md)) takes
either.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `root` | `EventTarget` | the event target requests travel to |
| `router` | [`UIRouterLit`](UIRouterLit.md) | the router to answer with |

## Returns

a function that uninstalls this provider

() => `void`

## Example

```ts
import { provideRouter } from 'lit-ui-router/context';
import type { UIRouterLit } from 'lit-ui-router';

declare const router: UIRouterLit;
// installed on globalThis by the @lit-labs/ssr DOM shim
declare const litServerRoot: EventTarget;

const uninstall = provideRouter(litServerRoot, router);
try {
  // …render…
} finally {
  uninstall();
}
```

## See

[withRouterSync](withRouterSync.md) for the slot the same render sets instead
