In React Router v5, the <Redirect /> component navigates programmatically by redirecting the user from one route to another.
Purpose:
Automatically redirect from one URL to another.
Commonly used for authentication, route protection, or URL restructuring.
Example:
import { Redirect } from "react-router-dom";
function PrivateRoute({ isAuthenticated }) {
return isAuthenticated ? <Dashboard /> : <Redirect to="/login" />;
}