Create a ProtectedRoute Component in React Router

InstructorJason Brown

Share this video with your friends

Send Tweet

In this lesson we'll create a protected route just for logged in users. We'll combine a Route with a render prop and use a loggedIn prop to determine if the route should be allowed to be accessed. Finally we'll use nav state to preserve the location the user visited and redirect them back to the protected route once they login.

Viktor Soroka
~ 6 years ago

@Jason Brown Cool lesson. The sound is quiet so it is a bit hard to hear.