this is a protected route component for react router dom v6 & above
npm install protected-route-react##### ProtectedRoute built for React Router Dom v6.
npm install protected-route-react
In App.js,import {ProtectedRoute} from "protected-route-react"
and
Way 1
Wrap your element inside of
like this
and put this in element
as
Way 2
Use Route as Wrapper
and
password as element
like this
and put all the routes you want to protect inside of this
as
| Parameter | Default | Description |
| --------------- | ------------ | --------------------------------------------------- |
| isAuthenticated | "null" | 'This is to check whether user is login or not' |
| adminRoute | "null" | "This is to make admin protected route |
| isAdmin | "null" | "This is to check whether user is admin or not |
| redirect | "/login" | "This is to set the redirecting url |
| redirectAdmin | "/profile" | "This is to set the redirecting url for admin route |
Please Must Install react-router-dom
My name is Abhishek Singh, a.k.a 6 pack programmer on YouTube.
Youtube - Click Here
Instagram - Click Here
Twitter- Click Here
LinkedIn - Click