react-router-protected-route

1.0.0 • Public • Published

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>

Readme

Keywords

none

Package Sidebar

Install

npm i react-router-protected-route

Weekly Downloads

2

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • jadengore