burakorkmez / mern-chat-app

Real Time Chat App | MERN && Socket.io && JWT
MIT License
623 stars 175 forks source link

feat: Root Layout and Protected Routes #23

Open manuelbento19 opened 3 weeks ago

manuelbento19 commented 3 weeks ago

To ensure that only authenticated users can access the Home route, I had to implement conditional redirection logic based on the user's authentication state. A common approach to doing this in React applications is to create a protected route component. What did I do?

With these changes, we can ensure that the Home page will only be accessible to authenticated users and that unauthenticated users will be redirected to the login page.