1.1.2 • Published 6 years ago

react-private-route v1.1.2

Weekly downloads
238
License
MIT
Repository
github
Last release
6 years ago

react-private-route

npm version styled with prettier

Declarative private routing for React

Working demo available at

Edit y0pw4kz8kx

Installation

Using npm:

$ npm i react-private-route

Using yarn:

$ yarn add react-private-route

Basic Usage

...
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
...
import PrivateRoute from 'react-private-route'
...

class App extends Component {
  render() {
    return (
     ...
        <Router>
          <div className={'main-container'}>
            <Switch>
              <Route path="/login" component={Login} />
              <PrivateRoute
                exact
                path="/"
                component={Home}
                isAuthenticated={!!isLoggedIn() /* this method returns true or false */}
              />
              <Route component={NotFound} />
            </Switch>
          </div>
        </Router>
     ...
    )
  }
}

export default App

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

Credits

React Private Route is built and maintained by @hansfpc.

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago