Question · JavaScript and React course · Module 6: React Router

Protected Routes

How do you implement a Protected Route in React Router?

Answer options

  • We create a component that checks authorization and conditionally renders children or Navigate to the login page
  • We add a password in the URL parameters of each protected path
  • We hide links in the navigation and hope the user won't type the URL manually
  • We exclusively use server-side middleware to block paths

You can check the correct answer by solving this task in the CodeWorlds game.