Accepted answer

You can use redirect component from react-router-dom. Here is the documentation page. This is the example usage based upon your situation.

<Route exact path="/view">
  {isAdmin ? <AdminPage /> :<Redirect to="/" />}

FYI, this is how you import it

import { Redirect } from "react-router-dom";


store a jwt token and verify the token on backend and see if the token corrsponds to the connected account trying to access url. If token is owned by an admin, return admin page otherwise an error page appear.

Related Query

More Query from same tag