I am trying to redirect a user on a button click in my nextjs app, pls how do I accomplish this?
            Asked
            
        
        
            Active
            
        
            Viewed 254 times
        
    0
            
            
        - 
                    Are you trying to redirect back from within the client code, or on the server side with Nextjs? Your question is a bit unclear. – Drew Reese Feb 17 '22 at 08:17
 - 
                    1Can you update your question to include all relevant code you are trying to work with in a [minimal, complete, and reproducible code example](https://stackoverflow.com/help/minimal-reproducible-example)? – Drew Reese Feb 17 '22 at 08:34
 - 
                    I see, so you are asking how to make the UI code redirect back after authentication. Does this answer your question? https://stackoverflow.com/a/66289280/8690857 If not, then can you update your question to include all relevant UI code handling this authentication check and redirection to login route/component? – Drew Reese Feb 17 '22 at 17:56
 - 
                    Does this help answer your question: [How to redirect back to private route after login in Next.js?](https://stackoverflow.com/a/70689821/1870780)? You'll need to implement your own logic to redirect back to the previous page. – juliomalves Feb 18 '22 at 23:54
 - 
                    I want the user to return to what they're doing before redirecting them – Paulliano Feb 19 '22 at 05:07
 
1 Answers
0
            I later made this work by using router.push('/') https://nextjs.org/docs/api-reference/next/router
        Paulliano
        
- 347
 - 1
 - 5
 - 15