1.0.0 • Published 7 years ago

react-router-protected-route v1.0.0

Weekly downloads
12
License
Apache-2.0
Repository
github
Last release
7 years ago

react-router-protected-route

Build Status

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>