Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

VideoAmp/react-router-protected-route

Repository files navigation

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>

About

Route component that redirects unauthenticated users trying to access an auth-required route.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •