https://github.com/adriantoine/preact-enroute
Small preact router (preact port of https://github.com/tj/react-enroute)
https://github.com/adriantoine/preact-enroute
Last synced: 5 months ago
JSON representation
Small preact router (preact port of https://github.com/tj/react-enroute)
- Host: GitHub
- URL: https://github.com/adriantoine/preact-enroute
- Owner: adriantoine
- License: mit
- Created: 2016-09-04T14:35:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-07T14:47:54.000Z (over 8 years ago)
- Last Synced: 2025-05-12T23:53:46.827Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
This is a port of [react-enroute](https://github.com/tj/react-enroute) for [Preact](https://preactjs.com). It works exactly the same way, I only adapted the code style to mine as I am going to maintain this one. I have also reorganised the examples and added an example using hash history.
[](https://travis-ci.org/adriantoine/preact-enroute)
[](https://codecov.io/gh/adriantoine/preact-enroute)
[](https://www.npmjs.com/package/preact-enroute)
[](https://gemnasium.com/github.com/adriantoine/preact-enroute)# preact-enroute
Simple Preact router with a small footprint for modern browsers. This package is not meant to be a drop-in replacement for any router, just a smaller simpler alternative.
See [path-to-regexp](https://github.com/pillarjs/path-to-regexp) for path matching, this is the same library used by Express.
If you want to try it, play with it on [this CodePen (using hash history)](http://codepen.io/Alshten/pen/qaENkj), [on WebpackBin](http://www.webpackbin.com/NkS7tXIi-) or run the examples (see below).
## Installation
```
$ npm install preact-enroute
```## Examples
No nesting:
```js
render(
,
document.querySelector('#app')
);
```Some nesting:
```js
render(
,
document.querySelector('#app')
);
```Moar nesting:
```js
render(
,
document.querySelector('#app')
);
```## Developing
Build:
```
$ npm run build
```Start pushState example:
```
$ npm run example-pushstate
```Start hash example:
```
$ npm run example-hash
```Running tests:
```
$ npm test
```