score:0

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="/" />}
</Route>

FYI, this is how you import it

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

score:0

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