Unverified Commit acd7610f authored by Joseph's avatar Joseph Committed by GitHub

docs: server actions guide x-refs (#95143)

Before this guide existed, often we linked, incorrectly, to
mutating-data. Also adding more related links pointing to this guide.
parent 557ec030
...@@ -118,7 +118,7 @@ See the [`revalidateTag` API reference](/docs/app/api-reference/functions/revali ...@@ -118,7 +118,7 @@ See the [`revalidateTag` API reference](/docs/app/api-reference/functions/revali
## `updateTag` ## `updateTag`
`updateTag` immediately expires cached data for read-your-own-writes scenarios — the user sees their change right away instead of stale content. Unlike `revalidateTag`, it can only be used in [Server Actions](/docs/app/getting-started/mutating-data). `updateTag` immediately expires cached data for read-your-own-writes scenarios — the user sees their change right away instead of stale content. Unlike `revalidateTag`, it can only be used in [Server Actions](/docs/app/guides/server-actions).
```tsx filename="app/lib/actions.ts" highlight={1,12} switcher ```tsx filename="app/lib/actions.ts" highlight={1,12} switcher
import { updateTag } from 'next/cache' import { updateTag } from 'next/cache'
......
...@@ -1456,7 +1456,7 @@ This pattern allows you to show or hide UI elements based on user permissions wh ...@@ -1456,7 +1456,7 @@ This pattern allows you to show or hide UI elements based on user permissions wh
### Server Actions ### Server Actions
Treat [Server Actions](/docs/app/getting-started/mutating-data) with the same security considerations as public-facing API endpoints, and verify if the user is allowed to perform a mutation. Treat [Server Actions](/docs/app/guides/server-actions) with the same security considerations as public-facing API endpoints, and verify if the user is allowed to perform a mutation.
In the example below, we check the user's role before allowing the action to proceed: In the example below, we check the user's role before allowing the action to proceed:
......
...@@ -897,7 +897,7 @@ For these, use community libraries like [`swr`](https://swr.vercel.app/) or [`re ...@@ -897,7 +897,7 @@ For these, use community libraries like [`swr`](https://swr.vercel.app/) or [`re
### Server Actions ### Server Actions
Server Actions let you run server-side code from the client. Their primary purpose is to mutate data from your frontend client. [Server Actions](/docs/app/guides/server-actions) let you run server-side code from the client. Their primary purpose is to mutate data from your frontend client.
Server Actions are queued. Using them for data fetching introduces sequential execution. Server Actions are queued. Using them for data fetching introduces sequential execution.
......
...@@ -25,7 +25,7 @@ Next.js can automatically code split your JavaScript bundles, and generate multi ...@@ -25,7 +25,7 @@ Next.js can automatically code split your JavaScript bundles, and generate multi
The [`next/link`](/docs/app/api-reference/components/link) component automatically [prefetches](/docs/app/api-reference/components/link#prefetch) routes, giving you the fast page transitions of a strict SPA, but with the advantage of persisting application routing state to the URL for linking and sharing. The [`next/link`](/docs/app/api-reference/components/link) component automatically [prefetches](/docs/app/api-reference/components/link#prefetch) routes, giving you the fast page transitions of a strict SPA, but with the advantage of persisting application routing state to the URL for linking and sharing.
Next.js can start as a static site or even a strict SPA where everything is rendered client-side. If your project grows, Next.js allows you to progressively add more server features (e.g. [React Server Components](/docs/app/getting-started/server-and-client-components), [Server Actions](/docs/app/getting-started/mutating-data), and more) as needed. Next.js can start as a static site or even a strict SPA where everything is rendered client-side. If your project grows, Next.js allows you to progressively add more server features (e.g. [React Server Components](/docs/app/getting-started/server-and-client-components), [Server Actions](/docs/app/guides/server-actions), and more) as needed.
## Examples ## Examples
......
...@@ -401,6 +401,6 @@ export default async function PostPage({ params }) { ...@@ -401,6 +401,6 @@ export default async function PostPage({ params }) {
} }
``` ```
See the [Server Actions](/docs/app/getting-started/mutating-data) docs for more examples. See [Mutating data](/docs/app/getting-started/mutating-data) for more examples.
</AppOnly> </AppOnly>
...@@ -4,6 +4,7 @@ description: API Reference for the redirect function. ...@@ -4,6 +4,7 @@ description: API Reference for the redirect function.
related: related:
links: links:
- app/api-reference/functions/permanentRedirect - app/api-reference/functions/permanentRedirect
- app/guides/server-actions
--- ---
The `redirect` function allows you to redirect the user to another URL. `redirect` can be used while rendering in [Server and Client Components](/docs/app/getting-started/server-and-client-components), [Route Handlers](/docs/app/api-reference/file-conventions/route), and [Server Functions](/docs/app/getting-started/mutating-data). The `redirect` function allows you to redirect the user to another URL. `redirect` can be used while rendering in [Server and Client Components](/docs/app/getting-started/server-and-client-components), [Route Handlers](/docs/app/api-reference/file-conventions/route), and [Server Functions](/docs/app/getting-started/mutating-data).
......
--- ---
title: refresh title: refresh
description: API Reference for the refresh function. description: API Reference for the refresh function.
related:
links:
- app/guides/server-actions
--- ---
`refresh` allows you to refresh the client router from within a [Server Action](/docs/app/getting-started/mutating-data). `refresh` allows you to refresh the client router from within a [Server Action](/docs/app/guides/server-actions).
## Usage ## Usage
......
--- ---
title: revalidatePath title: revalidatePath
description: API Reference for the revalidatePath function. description: API Reference for the revalidatePath function.
related:
links:
- app/guides/server-actions
--- ---
`revalidatePath` allows you to invalidate [cached data](/docs/app/getting-started/caching) on-demand for a specific path. `revalidatePath` allows you to invalidate [cached data](/docs/app/getting-started/caching) on-demand for a specific path.
......
--- ---
title: revalidateTag title: revalidateTag
description: API Reference for the revalidateTag function. description: API Reference for the revalidateTag function.
related:
links:
- app/guides/server-actions
--- ---
`revalidateTag` allows you to invalidate cached data on-demand for a specific cache tag. `revalidateTag` allows you to invalidate cached data on-demand for a specific cache tag.
......
--- ---
title: serverActions title: serverActions
description: Configure Server Actions behavior in your Next.js application. description: Configure Server Actions behavior in your Next.js application.
related:
links:
- app/guides/server-actions
--- ---
Options for configuring Server Actions behavior in your Next.js application. Options for configuring Server Actions behavior in your Next.js application. For how Server Actions work, including the security boundary these options tune, see the [Server Actions guide](/docs/app/guides/server-actions).
## `allowedOrigins` ## `allowedOrigins`
......
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