Skip to content

Conversation

icyJoseph
Copy link
Contributor

@icyJoseph icyJoseph commented Sep 22, 2025

As of v15, redirect, and also permanentRedirect, can be invoked from event handlers, and effects.

Closes: https://linear.app/vercel/issue/DOC-5097/redirect-can-be-called-in-event-handlerseffects

@ijjk ijjk added created-by: Next.js DevEx team PRs by the DX team. Documentation Related to Next.js' official documentation. labels Sep 22, 2025
@icyJoseph icyJoseph marked this pull request as ready for review September 24, 2025 13:51
---

The `permanentRedirect` function allows you to redirect the user to another URL. `permanentRedirect` can be used in Server Components, Client Components, [Route Handlers](/docs/app/api-reference/file-conventions/route), and [Server Actions](/docs/app/getting-started/updating-data).
The `permanentRedirect` function allows you to redirect the user to another URL. `permanentRedirect` can be used in [Server and Client Components](/docs/app/getting-started/server-and-client-components), [Route Handlers](/docs/app/api-reference/file-conventions/route), and [Server Actions](/docs/app/getting-started/updating-data).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The permanentRedirect documentation mentions it can be used in Client Components but lacks the detailed explanation about event handlers and effects that redirect now includes.

View Details
📝 Patch Details
diff --git a/docs/01-app/03-api-reference/04-functions/permanentRedirect.mdx b/docs/01-app/03-api-reference/04-functions/permanentRedirect.mdx
index e2e58db64d..af3cba7746 100644
--- a/docs/01-app/03-api-reference/04-functions/permanentRedirect.mdx
+++ b/docs/01-app/03-api-reference/04-functions/permanentRedirect.mdx
@@ -6,7 +6,7 @@ related:
     - app/api-reference/functions/redirect
 ---
 
-The `permanentRedirect` function allows you to redirect the user to another URL. `permanentRedirect` can be used in [Server and Client Components](/docs/app/getting-started/server-and-client-components), [Route Handlers](/docs/app/api-reference/file-conventions/route), and [Server Actions](/docs/app/getting-started/updating-data).
+The `permanentRedirect` function allows you to redirect the user to another URL. `permanentRedirect` can be used in [Server and Client Components](/docs/app/getting-started/server-and-client-components), [Route Handlers](/docs/app/api-reference/file-conventions/route), and [Server Actions](/docs/app/getting-started/updating-data). It can also be called from Client Component event handlers and effects.
 
 When used in a streaming context, this will insert a meta tag to emit the redirect on the client side. When used in a server action, it will serve a 303 HTTP redirect response to the caller. Otherwise, it will serve a 308 (Permanent) HTTP redirect response to the caller.
 
@@ -59,4 +59,33 @@ export default async function Profile({ params }) {
 }
 ```
 
+### Client Component
+
+`permanentRedirect` can be called in Client Component event handlers and effects.
+
+```tsx filename="components/client-redirect-button.tsx"
+'use client'
+
+import { permanentRedirect } from 'next/navigation'
+
+export function ClientRedirectButton() {
+  return (
+    <button
+      onClick={() => {
+        permanentRedirect('/dashboard')
+      }}
+    >
+      Redirect to Dashboard
+    </button>
+  )
+}
+```
+
 > **Good to know**: `permanentRedirect` does not require you to use `return permanentRedirect()` as it uses the TypeScript [`never`](https://www.typescriptlang.org/docs/handbook/2/functions.html#never) type.
+
+## Version History
+
+| Version   | Changes                                                  |
+| --------- | -------------------------------------------------------- |
+| `v15.0.0` | `permanentRedirect` can be used in Client Components    |
+| `v13.0.0` | `permanentRedirect` introduced.                          |

Analysis

Inconsistent documentation between redirect and permanentRedirect functions

What fails: permanentRedirect documentation lacks explicit mention of Client Component event handlers and effects capabilities that were added in v15.0.0, while redirect documentation correctly documents these features.

How to reproduce:

  1. Compare docs/01-app/03-api-reference/04-functions/redirect.mdx and docs/01-app/03-api-reference/04-functions/permanentRedirect.mdx
  2. Notice redirect states "it can also be called from Client Component event handlers and effects" with event handler examples
  3. Notice permanentRedirect only mentions "can be used in Server and Client Components" without event handler details

Result: Documentation inconsistency where permanentRedirect appears to have fewer capabilities than redirect, despite both functions using identical underlying implementation and having the same capabilities.

Expected: Both functions should document identical Client Component capabilities per source code analysis showing both use the same getRedirectError() mechanism and have identical functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Next.js DevEx team PRs by the DX team. Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants