Skip to content

shaggyrec/react-protected-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 redirected
  • authPath - path to redirect

About

Protected Route for React Router

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published