React router with a small footprint for modern browsers
JavaScript HTML CSS Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github add some tests Jun 15, 2016
example fix props. Closes #12 Sep 20, 2016
test index route Jun 8, 2018
.babelrc add some tests Jun 15, 2016
.gitignore Initial commit Jun 15, 2016
Changelog.md changelog Jun 11, 2018
LICENSE Initial commit Jun 15, 2016
Makefile add some tests Jun 15, 2016
Readme.md readme: index route usage Jun 11, 2018
index.js index route Jun 8, 2018
package.json package.json: up to 2.0.0 Jun 11, 2018

Readme.md

react-enroute

Simple React router with a small footprint for modern browsers. This package is not meant to be a drop-in replacement for react-router, just a smaller simpler alternative.

See path-to-regexp for path matching, this is the same library used by Express.

Installation

$ npm install react-enroute

Examples

No nesting:

ReactDOM.render(<Router {...state}>
  <Route path="/" component={Index} />
  <Route path="/users" component={Users} />
  <Route path="/users/:id" component={User} />
  <Route path="/pets" component={Pets} />
  <Route path="/pets/:id" component={Pet} />
  <Route path="*" component={NotFound} />
</Router>, document.querySelector('#app'))

Some nesting:

ReactDOM.render(<Router {...state}>
  <Route component={Index} />

  <Route path="/users" component={Users}>
    <Route path=":id" component={User} />
  </Route>

  <Route path="/pets" component={PetsContainer}>
    <Route component={Pets} />
    <Route path=":id" component={Pet} />
  </Route>

  <Route path="*" component={NotFound} />
</Router>, document.querySelector('#app'))

Moar nesting:

ReactDOM.render(<Router {...state}>
  <Route path="/" component={Index}>
    <Route path="users" component={Users}>
      <Route path=":id" component={User} />
    </Route>

    <Route path="pets" component={Pets}>
      <Route path=":id" component={Pet} />
    </Route>
  </Route>

  <Route path="*" component={NotFound} />
</Router>, document.querySelector('#app'))

Developing

Build:

$ make build

Start dev server:

$ make start

Running tests:

$ make test

Badges


tjholowaychuk.com  ·  GitHub @tj  ·  Twitter @tjholowaychuk