'Popup which persists through page redirect Next.js (React)

I am using Next.js for one of the projects that I work on. I wonder if someone could help me with an advice on how to show a popup (popup component, I think it could be based on Alert or Modal or something) to user in browser when I redirect to a certain page. In my very case, I am implementing a password reset logic and on the page for setting new password I am verifying the token in the url. If that token is not valid I have an immediate redirect to login. I just want to give the user some general message like "Not successful" or something to indicate that reset did not work. This should be done as a popup in my opinion and should be shown for some seconds on login page that we land our user on.

Thank you in advance and wish you all good!



Solution 1:[1]

Try using react-toastify for notification

For example with @ernesto comment, my logic like this

React.useEffect(() => {
if (query === 'error') {
toast.error('Not successful')
}
}, [])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kholiq