Skip to content

Docs IA 2.0: Move Redirects page to guides #79447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/01-app/02-guides/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export async function createSession(userId) {
}
```

Back in your Server Action, you can invoke the `createSession()` function, and use the [`redirect()`](/docs/app/building-your-application/routing/redirecting) API to redirect the user to the appropriate page:
Back in your Server Action, you can invoke the `createSession()` function, and use the [`redirect()`](/docs/app/guides/redirecting) API to redirect the user to the appropriate page:

```ts filename="app/actions/auth.ts" switcher
import { createSession } from '@/app/lib/session'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Redirecting
title: How to handle redirects in Next.js
nav_title: Redirecting
description: Learn the different ways to handle redirects in Next.js.
related:
links:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default async function Profile({ params }) {
> - `redirect` internally throws an error so it should be called outside of `try/catch` blocks.
> - `redirect` can be called in Client Components during the rendering process but not in event handlers. You can use the [`useRouter` hook](#userouter-hook) instead.
> - `redirect` also accepts absolute URLs and can be used to redirect to external links.
> - If you'd like to redirect before the render process, use [`next.config.js`](/docs/app/building-your-application/routing/redirecting#redirects-in-nextconfigjs) or [Middleware](/docs/app/building-your-application/routing/redirecting#nextresponseredirect-in-middleware).
> - If you'd like to redirect before the render process, use [`next.config.js`](/docs/app/guides/redirecting#redirects-in-nextconfigjs) or [Middleware](/docs/app/guides/redirecting#nextresponseredirect-in-middleware).

See the [`redirect` API reference](/docs/app/api-reference/functions/redirect) for more information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ You could also use the returned state to display a toast message from the Client

### Handling Expected Errors from Server Components

When fetching data inside of a Server Component, you can use the response to conditionally render an error message or [`redirect`](/docs/app/building-your-application/routing/redirecting#redirect-function).
When fetching data inside of a Server Component, you can use the response to conditionally render an error message or [`redirect`](/docs/app/guides/redirecting#redirect-function).

```tsx filename="app/page.tsx" switcher
export default async function Page() {
Expand Down
2 changes: 1 addition & 1 deletion docs/01-app/05-api-reference/02-components/form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export default function Page() {
}
```

After a mutation, it's common to redirect to the new resource. You can use the [`redirect`](/docs/app/building-your-application/routing/redirecting) function from `next/navigation` to navigate to the new post page.
After a mutation, it's common to redirect to the new resource. You can use the [`redirect`](/docs/app/guides/redirecting) function from `next/navigation` to navigate to the new post page.

> **Good to know**: Since the "destination" of the form submission is not known until the action is executed, `<Form>` cannot automatically prefetch shared UI.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default async function Page() {
The following Next.js APIs rely on throwing an error which should be rethrown and handled by Next.js itself:

- [`notFound()`](/docs/app/api-reference/functions/not-found)
- [`redirect()`](/docs/app/building-your-application/routing/redirecting#redirect-function)
- [`permanentRedirect()`](/docs/app/building-your-application/routing/redirecting#permanentredirect-function)
- [`redirect()`](/docs/app/guides/redirecting#redirect-function)
- [`permanentRedirect()`](/docs/app/guides/redirecting#permanentredirect-function)

If a route segment is marked to throw an error unless it's static, a Dynamic API call will also throw an error that should similarly not be caught by the developer. Note that Partial Prerendering (PPR) affects this behavior as well. These APIs are:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
title: Redirecting
title: How to handle redirects in Next.js
nav_title: Redirecting
description: Learn the different ways to handle redirects in Next.js.
source: app/building-your-application/routing/redirecting
source: app/guides/redirecting
---

{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
Loading