react-route-extended
v1.0.0
Published
Authenticated Route support for React Router 4
Downloads
6
Maintainers
Readme
react-route-extended
Authenticated Route support for React Router 4
Why this is useful?
This simple component allows you to simplify creating routes in react which require authentication, by simply passing a boolean value as prop on your route component.
- Lightweight (less than 1kb)
- Supports both public and private routes - no need to manage multiple components
- Redirect to a custom route when authentication fails or fallback to the bundled route handler
- Wraps around the react-router-dom API so supports all standard
<Route />
features
Installation
$ npm install --save react-route-extended
# or
$ yarn add react-route-extended
Usage
Import Route
into your component
import Route from 'react-route-extended'
Create a public route
<Route path="/public" component={HomePage} />
Create a private route
<Route auth={isUserAuthenticated} path="/private" component={PrivatePage} />
Create a private route w/ a custom redirect
<Route auth={isUserAuthenticated} path="/private" component={PrivatePage} redirect={'/nope'} />