DEV Community

Discussion on: 🔐 Private Route in React Router v6

Collapse
 
masudur10 profile image
Masudur Rahman

In this react-router version 6 implementation,how i can show alert or popup message for unlogged user when i trying to navigate private route? if user not logged-in it will show the message "please login first" with login button to navigate login page.

if user not logged-in, user always navigate/redirected to home page or other public route.

Collapse
 
iamandrewluca profile image
Andrei Luca

See this example, when you do the redirect, you can pass some state
in the login component use that state to show the message

dev.to/iamandrewluca/comment/1jjm9