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.
1 reply
-
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The 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 information
No response
Example
https://codesandbox.io/p/devbox/y43hzg?embed=1&file=%2Fapp%2Ftest%2Fpage.tsx
Beta Was this translation helpful? Give feedback.
All reactions