How to use routr - 3 common examples

To help you get started, we’ve selected a few routr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jamesknelson / react-black-triangle / src / utils / router.js View on Github external
import Routr from "routr"

const router = new Routr({
  'triangle': {path: "/", method: "get"},
  'about': {path: "/about", method: "get"},
});

export default router;
github jamesknelson / react-black-triangle / src / utils / Router.js View on Github external
import Router from "routr"
import _ from "lodash"


const paths = {
  'about': "/about",
  'triangle': "/triangle",
};

const router = new Router(_.mapValues(paths, path => ({path: path, method: "get"})));


export function getLocation() {
  return window.location.hash.substr(1);
}

export function getRoute() {
  return router.getRoute(getLocation()) || {name: '404'};
}
github zordius / reservice / example / src / routing.js View on Github external
import Router from 'routr'
import { setTitle } from './actions/metaHeader'
import { yelpSearch, yelpBusiness } from './actions/yelp'

const routing = new Router({
  search: {
    path: '/',
    handler: (store, route) => store.dispatch(yelpSearch(route.query))
  },
  business: {
    path: '/business/:id',
    handler: (store, route) => store.dispatch(yelpBusiness(route.params.id))
      .then(action => store.dispatch(setTitle(action.payload.name)))
  }
})

export default routing

routr

A router for both server and client

Unrecognized
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis

Popular routr functions