unkown error NEXT_REDIRECT?
Unanswered
Transvaal lion posted this in #help-forum
Transvaal lionOP
dunno why this error comming
9 Replies
Transvaal lionOP
even im importing it correctly
Transvaal lionOP
bump
First time seeing this error so i have no idea.
Are you doing a try catch somewhere near this? Ik stupid question but just curious
Are you doing a try catch somewhere near this? Ik stupid question but just curious
Reason Im saying this: I maybe wrong but IIRC the way next js redirects is by throwing an error which then gets caught by NextJS itself and then the redirection happens.
@Transvaal lion dunno why this error comming
you cannot use
redirect inside an event handler. use router.push instead@joulev you cannot use `redirect` inside an event handler. use `router.push` instead
Transvaal lionOP
then what is use of redirect when i cant do conditional redirect?
@Transvaal lion then what is use of redirect when i cant do conditional redirect?
redirect should be called during the component render, not in event handlers. you can see a more detailed explanation here: https://github.com/vercel/next.js/pull/56067/files