# hirouter

> HTML5 history and router, simple, powerful and no framework.

Latest version **0.1.2** (published 2015-05-03) · 0 weekly downloads

## Install

```sh
npm install hirouter
pnpm add hirouter
yarn add hirouter
bun add hirouter
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-05-03 |
| First published | 2015-04-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Maintainers | zensh |
| Keywords | router, history, pushState, route |

## Links

- npm: https://www.npmjs.com/package/hirouter
- Repository: https://github.com/teambition/hirouter
- Issues: https://github.com/teambition/hirouter/issues
- npm.io page: https://npm.io/package/hirouter

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2015-05-03
- 0.1.1 — 2015-04-16
- 0.1.0 — 2015-04-16

## README

HiRouter
====
HTML5 history and router, simple, powerful and no framework.

[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]

**It is a implementation of [route-trie](https://github.com/zensh/route-trie)**

## Demo

```js
var HiRouter = require('hirouter');
var router = new HiRouter();

// define router handler:
router
  .when('/projects/:id', function(state) {
    // body...
    console.log(state)
    // {
    //   fragment: '/projects/xxxxxxxId?debug=true',
    //   pathName: '/projects/xxxxxxxId',
    //   search: '?debug=true',
    //   params: {
    //     id: 'xxxxxxxId'
    //   }
    // }
  })
  .when('/organizations/:id', function(state) {
    // body...
    console.log(state)
  })
  .otherwise(function(state) {
    // body...
  })
// start listen
router.start();

// navigate to a url
router.navigate('/organizations/xxxId')

// navigate to a url and don't trigger route handler
router.navigate('/organizations/xxxId', {trigger: false})
```

## API

### new HiRouter(rootPath, options)
### HiRouter.prototype.when(pattern, handler)
### HiRouter.prototype.otherwise(handler)
### HiRouter.prototype.navigate(fragment, options)
### HiRouter.prototype.start(options)
### HiRouter.prototype.route(fragment)
### HiRouter.prototype.parsePath(fragment)

### Object: HiRouter.prototype.history

[npm-url]: https://npmjs.org/package/hirouter
[npm-image]: http://img.shields.io/npm/v/hirouter.svg

[travis-url]: https://travis-ci.org/teambition/hirouter
[travis-image]: http://img.shields.io/travis/teambition/hirouter.svg

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