---
url: >-
  https://lit-ui-router.dev/v1/reference/ui-router-navigation-location-plugin/classes/NavigationLocationService.md
---
[ui-router-navigation-location-plugin](../index.md) / NavigationLocationService

# Class: NavigationLocationService

Defined in: index.ts:187

Location service implementation using the Navigation API.

Uses the browser's Navigation API for URL management instead of the
History API, providing better integration with browser navigation.

The service intercepts the navigations it starts, so a router transition
commits as a same-document navigation instead of loading the document
afresh. An application's extra work on those navigations — view
transitions, analytics, progress UI — goes through the
[intercept](../interfaces/NavigationLocationPluginOptions.md#intercept) option.

## See

https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API

## Extends

* [`BaseLocationServices`](https://ui-router.github.io/core/docs/latest/classes/_vanilla_baselocationservice_.baselocationservices.html)

## Constructors

### Constructor

```ts
new NavigationLocationService(router?, options?): NavigationLocationService;
```

Defined in: index.ts:201

Creates a new NavigationLocationService instance.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `router?` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) | The UIRouter instance (required despite optional type signature) |
| `options?` | [`NavigationLocationPluginOptions`](../interfaces/NavigationLocationPluginOptions.md) | How the service intercepts its own navigations |

#### Returns

`NavigationLocationService`

#### Throws

Error if router is not provided

#### Overrides

`BaseLocationServices.constructor`

## Methods

### \_navigation()

```ts
protected _navigation(): Navigation;
```

Defined in: index.ts:335

The Navigation API object this service drives.

Single seam for every `navigation` touch point. Override in a subclass to
substitute a stub — tests get to assert against the calls this service
makes without booting a browser to spy on a global.

#### Returns

`Navigation`

#### Example

```ts
import { NavigationLocationService } from 'ui-router-navigation-location-plugin';

class StubbedNavigationLocationService extends NavigationLocationService {
  stub!: Navigation;

  protected override _navigation(): Navigation {
    return this.stub;
  }
}
```

***

### dispose()

```ts
dispose(router): void;
```

Defined in: index.ts:412

Cleans up the location service by removing its Navigation API listeners.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `router` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) | The UIRouter instance |

#### Returns

`void`

#### Overrides

`BaseLocationServices.dispose`
