1.0.8 • Published 5 years ago

react-protected-route v1.0.8

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

react-protected-route

npm version Build Status NPM Packages NPM Dev Dependencies

A ReactJS route component that redirects users trying to access a protected route.

Example

The code below assumes isAuthenticated is true, and will render the protected route.

import ProtectedRoute from "react-protected-route";

// this can be read from your state which looks at 
// login and/or any logic to protect certain routes.
const isLoggedIn = false; 

// Example usage
const Routes = () => 
<Switch>
    <ProtectedRoute
        isAuthenticated={isLoggedIn}
        redirectTo="/login"
        path="/myaccount"
        component={() => <p>Protected account access</p>}
    />
    <Route
        path="/login"
        render={() => <p>Please sign in to access your account.</p>}
    />
</Switch>;
1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago