Skip to content

Conversation

@karlhorky
Copy link
Contributor

@karlhorky karlhorky commented Oct 2, 2025

What?

Make a note about the $ACTION_ properties in formData

Why?

Starting with next@14.1.3, $ACTION_ properties have appeared in the formData, which cause validation errors when used with a strict validation with a library such as Zod or Yup:

// Form Client Component
export default function Form() {
  const [state, formAction] = useFormState(action, {
    type: 'initial',
  });

  return (
    <form action={action}>
      {/* ... */}
    </form>
  );
}

// Server Action
export async function action(
  prevState: ServerActionReturnValue,
  formData: FormData,
): Promise<ServerActionReturnValue> {
  const validationResult = await schema.validate(
    Object.fromEntries(formData.entries()),
  );

The errors from Yup:

Errors:

  • this field has unspecified keys: $ACTION_REF_1, $ACTION_1:0, $ACTION_1:1, $ACTION_KEY
    The data in the formData.entries()
{
  '$ACTION_REF_1': '',
  '$ACTION_1:0': '{"id":"59f475b...","bound":"$@1"}',
  '$ACTION_1:1': '[{"type":"initial"}]',
  '$ACTION_KEY': 'k187677481',
  // Real form data starts here:
  year: '2024',

How?

  1. Document additional properties with keys starting with the prefix $ACTION_
  2. Remove the obsolete mention of .entries(), since that is not being used in the code example anymore (previously, it was const rawFormData = Object.fromEntries(formData.entries()))

History

cc @delbaoliveira

@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Oct 2, 2025
@ijjk
Copy link
Member

ijjk commented Oct 2, 2025

Allow CI Workflow Run

  • approve CI run for commit: 105affc

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

1 similar comment
@ijjk
Copy link
Member

ijjk commented Oct 2, 2025

Allow CI Workflow Run

  • approve CI run for commit: 105affc

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@icyJoseph
Copy link
Collaborator

This happens in prod too right? In v15.5.4, I see $_ACTION_ID_<id>.

LGTM though.

@karlhorky
Copy link
Contributor Author

@icyJoseph what do you think, is this ready to be merged?

@icyJoseph icyJoseph merged commit 0b14eb2 into vercel:canary Oct 9, 2025
67 checks passed
@karlhorky
Copy link
Contributor Author

Thanks for the review and merge!

@karlhorky karlhorky deleted the patch-3 branch October 10, 2025 06:06
icyJoseph added a commit that referenced this pull request Oct 10, 2025
…84459)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

Make a note about the `$ACTION_` properties in `formData`

### Why?

Starting with next@14.1.3, `$ACTION_` properties have appeared in the
`formData`, which cause validation errors when used with a strict
validation with a library such as Zod or Yup:

```tsx
// Form Client Component
export default function Form() {
  const [state, formAction] = useFormState(action, {
    type: 'initial',
  });

  return (
    <form action={action}>
      {/* ... */}
    </form>
  );
}

// Server Action
export async function action(
  prevState: ServerActionReturnValue,
  formData: FormData,
): Promise<ServerActionReturnValue> {
  const validationResult = await schema.validate(
    Object.fromEntries(formData.entries()),
  );
```

The errors from Yup:

Errors:

- this field has unspecified keys: $ACTION_REF_1, $ACTION_1:0,
$ACTION_1:1, $ACTION_KEY
The data in the formData.entries()

```js
{
  '$ACTION_REF_1': '',
  '$ACTION_1:0': '{"id":"59f475b...","bound":"$@1"}',
  '$ACTION_1:1': '[{"type":"initial"}]',
  '$ACTION_KEY': 'k187677481',
  // Real form data starts here:
  year: '2024',
```

### How?

1. Document additional properties with keys starting with the prefix
`$ACTION_`
2. Remove the obsolete mention of `.entries()`, since that is not being
used in the code example anymore (previously, it was `const rawFormData
= Object.fromEntries(formData.entries())`)

### History

- The `$ACTION_` property change was added in
#63048
- The `docs/01-app/02-guides/forms.mdx` file was added in PR
#79288 , without the `$ACTION_`
property change

cc @delbaoliveira

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Documentation Related to Next.js' official documentation. locked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants