From 2958054ae58140e4d78b074cf16d212f9570ba81 Mon Sep 17 00:00:00 2001 From: Joseph Chamochumbi Date: Tue, 12 Aug 2025 00:03:14 +0200 Subject: [PATCH 1/5] docs: Sequential server functions --- docs/01-app/01-getting-started/08-updating-data.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/01-app/01-getting-started/08-updating-data.mdx b/docs/01-app/01-getting-started/08-updating-data.mdx index e21ad528dabe5..5ddfccbe2e062 100644 --- a/docs/01-app/01-getting-started/08-updating-data.mdx +++ b/docs/01-app/01-getting-started/08-updating-data.mdx @@ -172,6 +172,8 @@ There are two main ways you can invoke a Server Function: 1. [Forms](#forms) in Server and Client Components 2. [Event Handlers](#event-handlers) and [useEffect](#useeffect) in Client Components +> **Good to know:** Server Functions are designed for server-side mutations. The client currently dispatches and awaits them one at a time. This is an implementation detail and may change. If you need parallel data fetching, use data fetching in Server Components, or perform parallel work inside a single Server Function or Route Handler. + ### Forms React extends the HTML [`
`](https://react.dev/reference/react-dom/components/form) element to allow Server Function to be invoked with the HTML `action` prop. From d37a4d1f800fdff33ec5e465fa21de208d49dc29 Mon Sep 17 00:00:00 2001 From: Joseph Chamochumbi Date: Tue, 12 Aug 2025 00:03:34 +0200 Subject: [PATCH 2/5] docs: revalidatePath/Tag + redirect --- docs/01-app/01-getting-started/08-updating-data.mdx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/01-app/01-getting-started/08-updating-data.mdx b/docs/01-app/01-getting-started/08-updating-data.mdx index 5ddfccbe2e062..786dbdf9fdb76 100644 --- a/docs/01-app/01-getting-started/08-updating-data.mdx +++ b/docs/01-app/01-getting-started/08-updating-data.mdx @@ -357,17 +357,19 @@ export async function createPost(formData) { ### Redirecting -You may want to redirect the user to a different page after performing an update. You can do this by calling [`redirect`](/docs/app/api-reference/functions/redirect) within the Server Function: +You may want to redirect the user to a different page after performing an update. You can do this by calling [`redirect`](/docs/app/api-reference/functions/redirect) within the Server Function. ```ts filename="app/lib/actions.ts" switcher 'use server' +import { revalidatePath } from 'next/cache' import { redirect } from 'next/navigation' export async function createPost(formData: FormData) { // Update data // ... + revalidatePath('/posts') redirect('/posts') } ``` @@ -375,16 +377,20 @@ export async function createPost(formData: FormData) { ```js filename="app/actions.js" switcher 'use server' +import { revalidatePath } from 'next/cache' import { redirect } from 'next/navigation' export async function createPost(formData) { // Update data // ... + revalidatePath('/posts') redirect('/posts') } ``` +Calling `redirect` [throws](/docs/app/api-reference/functions/redirect#behavior) a framework handled control-flow exception. Any code after it won't execute. If you need fresh data, call [`revalidatePath`](/docs/app/api-reference/functions/revalidatePath) or [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) beforehand. + ### Cookies You can `get`, `set`, and `delete` cookies inside a Server Action using the [`cookies`](/docs/app/api-reference/functions/cookies) API: From beca6b48953f50b29925648c5385cad4362dc7d8 Mon Sep 17 00:00:00 2001 From: Joseph Chamochumbi Date: Tue, 12 Aug 2025 00:04:17 +0200 Subject: [PATCH 3/5] docs: prod check list global-error and global-not-found --- docs/01-app/02-guides/production-checklist.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/01-app/02-guides/production-checklist.mdx b/docs/01-app/02-guides/production-checklist.mdx index 2dc62274cb62d..65fc18faa4318 100644 --- a/docs/01-app/02-guides/production-checklist.mdx +++ b/docs/01-app/02-guides/production-checklist.mdx @@ -84,6 +84,8 @@ While building your application, we recommend using the following features to en - **[Forms and Validation](/docs/app/guides/forms):** Use Server Actions to handle form submissions, server-side validation, and handle errors. +- **[Global Error UI](/docs/app/api-reference/file-conventions/error#global-error):** Add `app/global-error.tsx` to provide consistent, accessible fallback UI and recovery for uncaught errors across your app. +- **[Global 404](/docs/app/api-reference/file-conventions/not-found#global-not-found-js-experimental):** Add `app/global-not-found.tsx` to serve an accessible 404 for unmatched routes across your app. From c2ba83d2e0b945bf06604679673524ba8d03124a Mon Sep 17 00:00:00 2001 From: Joseph Chamochumbi Date: Tue, 12 Aug 2025 00:22:23 +0200 Subject: [PATCH 4/5] chore: broken hash link --- docs/01-app/02-guides/production-checklist.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/01-app/02-guides/production-checklist.mdx b/docs/01-app/02-guides/production-checklist.mdx index 65fc18faa4318..49bf12a80a538 100644 --- a/docs/01-app/02-guides/production-checklist.mdx +++ b/docs/01-app/02-guides/production-checklist.mdx @@ -85,7 +85,7 @@ While building your application, we recommend using the following features to en - **[Forms and Validation](/docs/app/guides/forms):** Use Server Actions to handle form submissions, server-side validation, and handle errors. - **[Global Error UI](/docs/app/api-reference/file-conventions/error#global-error):** Add `app/global-error.tsx` to provide consistent, accessible fallback UI and recovery for uncaught errors across your app. -- **[Global 404](/docs/app/api-reference/file-conventions/not-found#global-not-found-js-experimental):** Add `app/global-not-found.tsx` to serve an accessible 404 for unmatched routes across your app. +- **[Global 404](/docs/app/api-reference/file-conventions/not-found#global-not-foundjs-experimental):** Add `app/global-not-found.tsx` to serve an accessible 404 for unmatched routes across your app. From 9988208289d7abc4356f5f811bbf16c912f17318 Mon Sep 17 00:00:00 2001 From: Joseph Chamochumbi Date: Tue, 12 Aug 2025 13:53:40 +0200 Subject: [PATCH 5/5] docs: Point to relevant docs for data fetching --- docs/01-app/01-getting-started/08-updating-data.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/01-app/01-getting-started/08-updating-data.mdx b/docs/01-app/01-getting-started/08-updating-data.mdx index 786dbdf9fdb76..693283d8fca8a 100644 --- a/docs/01-app/01-getting-started/08-updating-data.mdx +++ b/docs/01-app/01-getting-started/08-updating-data.mdx @@ -172,7 +172,7 @@ There are two main ways you can invoke a Server Function: 1. [Forms](#forms) in Server and Client Components 2. [Event Handlers](#event-handlers) and [useEffect](#useeffect) in Client Components -> **Good to know:** Server Functions are designed for server-side mutations. The client currently dispatches and awaits them one at a time. This is an implementation detail and may change. If you need parallel data fetching, use data fetching in Server Components, or perform parallel work inside a single Server Function or Route Handler. +> **Good to know:** Server Functions are designed for server-side mutations. The client currently dispatches and awaits them one at a time. This is an implementation detail and may change. If you need parallel data fetching, use [data fetching](/docs/app/getting-started/fetching-data#server-components) in Server Components, or perform parallel work inside a single Server Function or [Route Handler](/docs/app/guides/backend-for-frontend#manipulating-data). ### Forms