Skip to content

fourcolors/mr-react-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 Mr. React Router Stash

Mr React Router

Simple react router than can get you up and running in 5 minutes

Setup

  1. npm install mr-react-router --save or yarn install mr-react-router
  2. Include the router by importing it ie: import Router from 'mr-react-router'
  3. Declare routes and pass the to the router:
import Main from './main' // main is a component you define

const isLoggedIn = () =>  {
  // any logic that returns true or false. True will return trigger the redirect
  return true
}

const routes = [{
  path: '/',
  component: Main,
  check: isLoggedIn,
  redirect: '/login',
}]

const App = () => {
  return (
    <Provider store={store}>
      <Router routes={routes} />
    </Provider>
  )
}

This is just the start

Almost anyone can understand this type of router and it's flexible for 90% of the use cases. I'll be adding the following in the future:

To Do

  • Grouped route checks
  • React hooks
  • Link to helpers
  • Named routes
  • Better async support

About

Simple react router than can get you up and running in 5 minutes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published