← React Intermediate Questions - Set 4 Q37

How do you handle authentication in a React application?

React Intermediate Questions - Set 4

Example

function Private({ children }) {
  const { token } = useAuth();
  return token ? children : <Navigate to="/login" replace />;
}

What to notice

← Back to the question list