react-router-protected-route
v1.0.0
Published
Route component that redirects unauthenticated users trying to access an auth-required route.
Downloads
10
Readme
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>