# laco-inferno-router

> Inferno Laco Router management

Latest version **0.4.0** (published 2018-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install laco-inferno-router
pnpm add laco-inferno-router
yarn add laco-inferno-router
bun add laco-inferno-router
```

## Health

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

Positive: has types; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2018-04-22 |
| First published | 2018-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 34.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 209 |
| Author | Deam Hansen |
| Maintainers | deam |

## Links

- npm: https://www.npmjs.com/package/laco-inferno-router
- Repository: https://github.com/deamme/laco
- Homepage: https://github.com/deamme/laco#readme
- Issues: https://github.com/deamme/laco/issues
- npm.io page: https://npm.io/package/laco-inferno-router

## Dependencies (3)

- [laco](https://npm.io/package/laco.md) ^0.4.0
- [history](https://npm.io/package/history.md) ^4.7.2
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^2.1.0

## Recent versions

- 0.4.0 (latest) — 2018-04-22
- 0.4.0-0 — 2018-04-22
- 0.3.0 — 2018-03-17
- 0.2.6-2 — 2018-03-17
- 0.2.6-1 — 2018-03-17
- 0.2.6-0 — 2018-03-17
- 0.2.5 — 2018-03-16
- 0.2.4 — 2018-03-16
- 0.2.3 — 2018-03-16
- 0.2.2 — 2018-03-14
- 0.2.1 — 2018-03-06
- 0.2.0 — 2018-03-05
- 0.1.2 — 2018-03-05
- 0.1.1 — 2018-03-03
- 0.1.0 — 2018-03-03
- … 4 more at https://npm.io/package/laco-inferno-router/versions

## README

# Laco Inferno Router
[![npm version](https://badge.fury.io/js/laco-inferno-router.svg)](https://badge.fury.io/js/laco-inferno-router)

`laco-inferno-router` is a replacement for [Redux First Router](https://github.com/faceyspacey/redux-first-router) which makes routing a part of the state.

Routing now works with time travel and you can dispatch routing related actions that get logged in the debugger.

## Example
```javascript
import { render } from 'inferno'
import { Store } from 'laco'
import { Subscribe } from 'laco-inferno'
import { Route, RouterStore, Switch, Link } from 'laco-inferno-router'

import Home from './pages/Home'
import Test from './pages/Test'
import NoMatch from './pages/NoMatch'

const Counter = () => (
  <Subscribe to={[RouterStore]}>
    {state => (
      <Switch location={state.pathname}>
        <Route exact path="/" component={Home} />
        <Route exact path="/test" component={Test} />
        <Route component={NoMatch} />
      </Switch>
    )}
  </Subscribe>
)

render(<Counter />, document.getElementById('root'))
```

Check out the `examples` folder.

## API
Refer to [React Router](https://github.com/ReactTraining/react-router) documentation for following components:
- Route
- Switch
- Link

### `RouterStore`
This is the main store for routing.
```javascript
// Getting the state of the store
RouterStore.get()
// Outputs something like:
// {
//   hash: "",
//   pathname: "/",
//   search: ""
// }
```

### Actions
You may want to have more control of the routing history. You can do that by dispatching following actions:
- push(path: string)
- replace(path: string)
- go(n: number)
- goBack()
- goForward()

```javascript
import { push } from 'laco-inferno-router'

push('/test')
```
Actions gets automatically logged in the debugger.

For more information check out the history API [here](https://github.com/ReactTraining/history#navigation).

## Credits
Heavily inspired by:
- [React Router](https://github.com/ReactTraining/react-router)
- [Redux First Router](https://github.com/faceyspacey/redux-first-router)

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