From 234a0cfde5e54173986b13ce88268f20e16ca0bc Mon Sep 17 00:00:00 2001 From: Akhil singh <2426akhil@gmail.com> Date: Tue, 19 Aug 2025 20:05:36 +0530 Subject: [PATCH 1/4] fix(docs): corrected broken link in server-functions.md --- src/content/reference/rsc/server-functions.md | 79 +++++++++---------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/src/content/reference/rsc/server-functions.md b/src/content/reference/rsc/server-functions.md index 2603c109926..714aef4a0e8 100644 --- a/src/content/reference/rsc/server-functions.md +++ b/src/content/reference/rsc/server-functions.md @@ -20,9 +20,9 @@ Server Functions allow Client Components to call async functions executed on the -#### How do I build support for Server Functions? {/*how-do-i-build-support-for-server-functions*/} +#### How do I build support for Server Functions? {/* how-do-i-build-support-for-server-functions */} -While Server Functions in React 19 are stable and will not break between minor versions, the underlying APIs used to implement Server Functions in a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x. +While Server Functions in React 19 are stable and will not break between minor versions, the underlying APIs used to implement Server Functions in a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x. To support Server Functions as a bundler or framework, we recommend pinning to a specific React version, or using the Canary release. We will continue working with bundlers and frameworks to stabilize the APIs used to implement Server Functions in the future. @@ -32,9 +32,9 @@ When a Server Function is defined with the [`"use server"`](/reference/rsc/use-s Server Functions can be created in Server Components and passed as props to Client Components, or they can be imported and used in Client Components. -## Usage {/*usage*/} +## Usage {/* usage */} -### Creating a Server Function from a Server Component {/*creating-a-server-function-from-a-server-component*/} +### Creating a Server Function from a Server Component {/* creating-a-server-function-from-a-server-component */} Server Components can define Server Functions with the `"use server"` directive: @@ -42,67 +42,65 @@ Server Components can define Server Functions with the `"use server"` directive: // Server Component import Button from './Button'; -function EmptyNote () { +function EmptyNote() { async function createNoteAction() { // Server Function 'use server'; - + await db.notes.create(); } - return + return ; } ``` For more, see the docs for [`"use server"`](/reference/rsc/use-server). - -### Importing Server Functions from Client Components {/*importing-server-functions-from-client-components*/} +### Importing Server Functions from Client Components {/* importing-server-functions-from-client-components */} Client Components can import Server Functions from files that use the `"use server"` directive: ```js [[1, 3, "createNote"]] -"use server"; +'use server'; export async function createNote() { await db.notes.create(); } - ``` When the bundler builds the `EmptyNote` Client Component, it will create a reference to the `createNote` function in the bundle. When the `button` is clicked, React will send a request to the server to execute the `createNote` function using the reference provided: ```js [[1, 2, "createNote"], [1, 5, "createNote"], [1, 7, "createNote"]] -"use client"; +'use client'; import {createNote} from './actions'; function EmptyNote() { console.log(createNote); // {$$typeof: Symbol.for("react.server.reference"), $$id: 'createNote'} - ; + return } ``` For more, see the docs for [`"use server"`](/reference/rsc/use-server). -### Importing Server Functions from Client Components {/* importing-server-functions-from-client-components */} + +### Importing Server Functions from Client Components {/*importing-server-functions-from-client-components*/} Client Components can import Server Functions from files that use the `"use server"` directive: ```js [[1, 3, "createNote"]] -'use server'; +"use server"; export async function createNote() { await db.notes.create(); @@ -83,24 +84,24 @@ export async function createNote() { When the bundler builds the `EmptyNote` Client Component, it will create a reference to the `createNote` function in the bundle. When the `button` is clicked, React will send a request to the server to execute the `createNote` function using the reference provided: ```js [[1, 2, "createNote"], [1, 5, "createNote"], [1, 7, "createNote"]] -'use client'; +"use client"; import {createNote} from './actions'; function EmptyNote() { console.log(createNote); // {$$typeof: Symbol.for("react.server.reference"), $$id: 'createNote'} -