Skip to content

Fix Server Functions documentation examples#8538

Open
smith558 wants to merge 5 commits into
reactjs:mainfrom
smith558:patch-13
Open

Fix Server Functions documentation examples#8538
smith558 wants to merge 5 commits into
reactjs:mainfrom
smith558:patch-13

Conversation

@smith558

@smith558 smith558 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #8537 + minor content improvements

@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@MaxwellCohen

MaxwellCohen commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Hi,

I am getting a client-side error on the server functions preview. This is usually caused by a misalignment of line numbers for function highlights.

Screenshot_20260719_082731_Chrome

Edit: This has been fixed!

@smith558

Copy link
Copy Markdown
Contributor Author

@MaxwellCohen thanks, will fix

Corrected the index of 'submitAction' in the code snippet.
@smith558

Copy link
Copy Markdown
Contributor Author

@MaxwellCohen fixed

@smith558

smith558 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

@MaxwellCohen @rickhanlonii @aurorascharff 🙂 please review

… transition comment

- Convert the remaining two Usage headings to gerund form to match the
  rest of the page and react.dev convention (anchors unchanged)
- Reset wording: "succeeds" + "the form's uncontrolled fields" (aligns with reactjs#8512)
- Comment the startTransition-after-await; bump CodeStep line accordingly

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Server Functions work with the new Form features in React 19.

You can pass a Server Function to a Form to automatically submit the form to the server:
You can pass a Server Function to a Form to automatically submit the form to the server. React passes the submitted `FormData` to the Server Function as its first argument:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add a link to MDN form data here so that users can see what is included in the form data
FormData link so users know what functions are available.

Suggested change
You can pass a Server Function to a Form to automatically submit the form to the server. React passes the submitted `FormData` to the Server Function as its first argument:
You can pass a Server Function to a Form to automatically submit the form to the server. React passes the submitted `[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)` to the Server Function as its first argument:

```

When the <CodeStep step={2}>permalink</CodeStep> is provided to `useActionState`, React will redirect to the provided URL if the form is submitted before the JavaScript bundle loads.
When the <CodeStep step={2}>permalink</CodeStep> is provided to `useActionState`, the browser will navigate to the provided URL if the form is submitted before the JavaScript bundle loads. At the destination, render `useActionState` with the same Server Function and permalink so React can pass the returned state to it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ I really like pointing out that this is browser behavior, not React behavior.

### Server Functions with `useActionState` {/*server-functions-with-use-action-state*/}
### Calling a Server Function with `useActionState` {/*server-functions-with-use-action-state*/}

You can call Server Functions with `useActionState` for the common case where you just need access to the action pending state and last returned response. The Server Function receives the previous state as its first argument and the submitted `FormData` as its second argument. Its return value becomes the next state:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can call Server Functions with `useActionState` for the common case where you just need access to the action pending state and last returned response. The Server Function receives the previous state as its first argument and the submitted `FormData` as its second argument. Its return value becomes the next state:
You can call Server Functions with `useActionState` for the common case where you need access to the Action's pending state and the last returned response. The Server Function receives the previous state as its first argument and the submitted `[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)` as its second argument. Its return value becomes the next state:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Mistakes]: Server Functions examples use incompatible action signatures

3 participants