1.0.0 • Published 7 years ago
react-router-protected-route v1.0.0
react-router-protected-route
A Route component that redirects unauthenticated users trying to access an auth-required route.
Example
The code below assumes isAccessible
is true
, and will render the protected route.
import ProtectedRoute from "react-router-protected-route";
<Switch>
<ProtectedRoute
isAccessible
redirectToPath="/login"
path="/"
component={() => <p>Logged in</p>}
/>
<Route
path="/login"
render={() => <p>Please sign in.</p>}
/>
</Switch>
1.0.0
7 years ago