react-basic-router

I published my first npm package today! It is called react-basic-router and it does pretty much what you would expect. Although it was a small project, I personally will find a lot of use from it. win-win.

The concept is simple. It is a hash router for reactJS. You can use it like this:

  import React from 'react';
  import {Router, Route} from 'react-basic-router';

  class App extends React.Component {
    render() {
      return(
        <Router>
          <Route hash="#/" component={PageA} />
          <Route hash="#/about" component={PageB} />
        </Router>
      );
    }
  }

It supports prop pass-through, so if you add more props to the <Route /> object, they will be pushed to the component when it renders. You can load one of these pages through regular anchor / hash links which must exactly match the hash prop.

There are some improvements I would like to make, such as an optional fuzzy matching for anchors. And perhaps an “Error” route for pages that don’t exist.

More to come. Enjoy!