Unverified Commit 21a1eafb authored by Joseph's avatar Joseph Committed by GitHub

docs: server actions guide (#93553)

Let's centralize our Server Actions education into a guide
parent b86f97bb
...@@ -2,15 +2,16 @@ ...@@ -2,15 +2,16 @@
title: Mutating Data title: Mutating Data
description: Learn how to mutate data using Server Functions and Server Actions in Next.js. description: Learn how to mutate data using Server Functions and Server Actions in Next.js.
related: related:
title: API Reference title: Next steps
description: Learn more about the features mentioned in this page by reading the API Reference. description: Learn more about Server Actions and the APIs mentioned in this page.
links: links:
- app/guides/server-actions
- app/api-reference/functions/revalidatePath - app/api-reference/functions/revalidatePath
- app/api-reference/functions/revalidateTag - app/api-reference/functions/revalidateTag
- app/api-reference/functions/redirect - app/api-reference/functions/redirect
--- ---
You can mutate data in Next.js using [React Server Functions](https://react.dev/reference/rsc/server-functions). This page will go through how you can [create](#creating-server-functions) and [invoke](#invoking-server-functions) Server Functions. You can mutate data in Next.js using [React Server Functions](https://react.dev/reference/rsc/server-functions). This page will go through how you can [create](#creating-server-functions) and [invoke](#invoking-server-functions) Server Functions. For Next.js-specific behaviors (single-roundtrip response, sequential dispatch, security, deployment), see [Server Actions and Mutations](/docs/app/guides/server-actions).
## What are Server Functions? ## What are Server Functions?
......
...@@ -9,6 +9,7 @@ related: ...@@ -9,6 +9,7 @@ related:
- app/guides/authentication - app/guides/authentication
- app/guides/content-security-policy - app/guides/content-security-policy
- app/guides/forms - app/guides/forms
- app/guides/server-actions
--- ---
[React Server Components](https://react.dev/reference/rsc/server-components) improve performance and simplify data fetching, but also shift where and how data is accessed, changing some of the traditional security assumptions for handling data in frontend apps. [React Server Components](https://react.dev/reference/rsc/server-components) improve performance and simplify data fetching, but also shift where and how data is accessed, changing some of the traditional security assumptions for handling data in frontend apps.
......
...@@ -4,7 +4,7 @@ nav_title: Forms ...@@ -4,7 +4,7 @@ nav_title: Forms
description: Learn how to create forms in Next.js with React Server Actions. description: Learn how to create forms in Next.js with React Server Actions.
--- ---
React Server Actions are [Server Functions](https://react.dev/reference/rsc/server-functions) that execute on the server. They can be called in Server and Client Components to handle form submissions. This guide will walk you through how to create forms in Next.js with Server Actions. React Server Actions are [Server Functions](https://react.dev/reference/rsc/server-functions) that execute on the server. They can be called in Server and Client Components to handle form submissions. This guide will walk you through how to create forms in Next.js with Server Actions. For Server Action behaviors beyond forms (single-roundtrip response, sequential dispatch, security, deployment), see [Server Actions and Mutations](/docs/app/guides/server-actions).
> [!WARNING] > [!WARNING]
> Always verify [authentication and authorization](/docs/app/guides/authentication) inside each Server Action, even if the form is only rendered on an authenticated page. See the [Data Security guide](/docs/app/guides/data-security) for more details. > Always verify [authentication and authorization](/docs/app/guides/authentication) inside each Server Action, even if the form is only rendered on an authenticated page. See the [Data Security guide](/docs/app/guides/data-security) for more details.
......
This diff is collapsed.
...@@ -5,6 +5,8 @@ description: Learn how to use the use server directive to execute code on the se ...@@ -5,6 +5,8 @@ description: Learn how to use the use server directive to execute code on the se
The `use server` directive designates a function or file to be executed on the **server side**. It can be used at the top of a file to indicate that all functions in the file are server-side, or inline at the top of a function to mark the function as a [Server Function](https://19.react.dev/reference/rsc/server-functions). This is a React feature. The `use server` directive designates a function or file to be executed on the **server side**. It can be used at the top of a file to indicate that all functions in the file are server-side, or inline at the top of a function to mark the function as a [Server Function](https://19.react.dev/reference/rsc/server-functions). This is a React feature.
For Next.js-specific Server Action behaviors (response model, security, configuration, deployment), see [Server Actions and Mutations](/docs/app/guides/server-actions).
## Using `use server` at the top of a file ## Using `use server` at the top of a file
The following example shows a file with a `use server` directive at the top. All functions in the file are executed on the server. The following example shows a file with a `use server` directive at the top. All functions in the file are executed on the server.
......
...@@ -231,7 +231,7 @@ The default component type in the App Router. Server Components render on the se ...@@ -231,7 +231,7 @@ The default component type in the App Router. Server Components render on the se
## Server Action ## Server Action
A [Server Function](#server-function) that is passed to a Client Component as a prop or bound to a form action. Server Actions are commonly used for form submissions and data mutations. Learn more in [Server Actions and Mutations](/docs/app/getting-started/mutating-data). A [Server Function](#server-function) that is passed to a Client Component as a prop or bound to a form action. Server Actions are commonly used for form submissions and data mutations. Learn more in [Server Actions and Mutations](/docs/app/guides/server-actions).
## Server Function ## Server Function
......
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