react-route-protected
v1.0.3
Published
Protected route for React Router
Downloads
8
Readme
ReactProtectedRoute
Protected react route. Use for redirect users to login page from private pages.
Installation
npm i react-route-protected
Usage
import { Switch } from 'react-router-dom';
...
<Switch>
...
<ReactProtectedRoute
path="/path-to-private-component"
component={PrivateComponent}
authPath="/login"
isAuthorized={authCondition}
/>
...
</Switch>
Props
path
- the same as path of Route component.component
- the same as component of Route component.isAuthorized
- if this condition is true user will be redirectedauthPath
- path to redirect