# router5-plugin-browser

> Router5 browser plugin

Latest version **8.0.1** (published 2020-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install router5-plugin-browser
pnpm add router5-plugin-browser
yarn add router5-plugin-browser
bun add router5-plugin-browser
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.1 |
| Published | 2020-03-19 |
| First published | 2018-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Thomas Roch |
| Maintainers | troch |
| Keywords | router5, helpers |

## Links

- npm: https://www.npmjs.com/package/router5-plugin-browser
- Repository: https://github.com/router5/router5
- Homepage: https://github.com/router5/router5/tree/master/packages/router5-plugin-browser
- Issues: https://github.com/router5/router5/issues
- npm.io page: https://npm.io/package/router5-plugin-browser

## Recent versions

- 8.0.1 (latest) — 2020-03-19
- 8.0.0 — 2020-03-01
- 7.0.2 — 2019-02-21
- 7.0.1 — 2018-12-21
- 7.0.0 — 2018-12-18

## README

# Router5 browser plugin

The browser plugin will automatically update your browser URL and state on route changes. It will also listen to popstate events (triggered by back and forward buttons and manual URL changes).

## Using the browser plugin

This plugin uses HTML5 history API and therefore is not compatible with browsers which don't support it. Refer to [caniuse.com](http://caniuse.com/#search=history) for browser compatibility.

It adds a bunch of functions to work with full URLs: `router.buildUrl(routeName, routeParams)` and `router.matchUrl(url)`. It also decorates the start function so you don't have to supply any start path (it extracts it from the current URL).

```js
import browserPlugin from 'router5-plugin-browser'

const router = createRouter()

router.usePlugin(
    browserPlugin({
        useHash: true
    })
)

router.start()
```

## Plugin options

-   `forceDeactivate`: default to `true`, meaning `canDeactivate` handlers won't get called on popstate events. It is not recommended to set it to `false`.
-   `useHash`
-   `hashPrefix`
-   `base`: the base of your application (the part to add / preserve between your domain and your route paths).
-   `preserveHash`: whether to preserve the initial hash value on page load (default to `true`, only if `useHash` is `false`)
-   `mergeState`: whether to keep any value added in history state by a 3rd party or not (default to `false`)

---
_Source: https://npm.io/package/router5-plugin-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
