-
SummaryThe official documentation mentions that "redirect" can be called in Client Components during the rendering process but not in event handlers. However, after testing, I found that it actually works fine in client component event handlers. Is this a bug or expected behavior? Can I use it in a production environment? Additional informationNo response Examplehttps://codesandbox.io/p/devbox/y43hzg?embed=1&file=%2Fapp%2Ftest%2Fpage.tsx |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Mmmm in Next 14 it wasn't possible, because the redirect error thrown is not caught by the |
Beta Was this translation helpful? Give feedback.
-
it could break in future releases, because the Next.js team hasn’t committed to supporting redirect() in event handlers. For event-driven navigations on the client, the recommended approach is to use the useRouter() hook and call router.push() or router.replace(). |
Beta Was this translation helpful? Give feedback.
Alright, so we'll update the docs 😃