Unverified Commit fa100e29 authored by Gonzalo Pozzo's avatar Gonzalo Pozzo Committed by GitHub

Update docs with a Good to know box about using redirect in client components (#56966)

This adds a new `Good to know` box to explain how to programmatically
redirect in Client Components to avoid people using `redirect` inside
handlers.


![image](https://github.com/vercel/next.js/assets/6494462/20858591-3d21-4a48-bbc9-8a1e0de29ca8)
Co-authored-by: 's avatarLee Robinson <me@leerob.io>
parent 423e945e
...@@ -36,6 +36,8 @@ The `type` parameter has no effect when used in Server Components. ...@@ -36,6 +36,8 @@ The `type` parameter has no effect when used in Server Components.
Invoking the `redirect()` function throws a `NEXT_REDIRECT` error and terminates rendering of the route segment in which it was thrown. Invoking the `redirect()` function throws a `NEXT_REDIRECT` error and terminates rendering of the route segment in which it was thrown.
> **Good to know**: If you need to programmatically redirect the user after a certain event in a Client Component, you can use the [`useRouter`](/docs/app/api-reference/functions/use-router) hook.
```jsx filename="app/team/[id]/page.js" ```jsx filename="app/team/[id]/page.js"
import { redirect } from 'next/navigation' import { redirect } from 'next/navigation'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment