Protected Routes Quiz

Test your knowledge of protected routes in React Router, including auth checks, redirects, loader guards, role checks, and preserving intended destinations.

20 questions · free · answers explained

Start the quiz

All questions in this quiz

  1. What is a protected route in a React app?
  2. What should a protected route usually do when the user is not authenticated?
  3. Which React Router component can redirect when it is rendered?
  4. Why is replace often used when redirecting an unauthenticated user to login?
  5. What is a common reason to save the attempted destination before redirecting to login?
  6. Which hook is commonly used to read the current location before redirecting?
  7. In React Router data routes, where can an auth redirect happen before rendering the route element?
  8. Which React Router utility creates a redirect response from a loader or action?
  9. Why are loader-based auth checks useful?
  10. Do client-side protected routes replace server-side authorization?
  11. What is role-based route protection?
  12. What should a route guard show while authentication status is still loading?
  13. Which component is useful for rendering child routes inside a protected layout?
  14. What does a protected layout route help avoid?
  15. What is a common behavior after a user logs out?
  16. Why should redirect targets from user input be validated?
  17. Which auth state should generally not be trusted by itself for API security?
  18. What is the main UX risk of redirecting before auth status is known?
  19. When might an access denied page be better than a login redirect?
  20. What should protected route tests usually verify?

Prefer to read first? React interview questions with written answers.