Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(docs) Document Server Actions .bind method #56164

Merged
merged 4 commits into from Sep 28, 2023
Merged

(docs) Document Server Actions .bind method #56164

merged 4 commits into from Sep 28, 2023

Conversation

shuding
Copy link
Member

@shuding shuding commented Sep 28, 2023

This will be the recommended way of passing extra arguments to a Server Action. A couple of reasons behind:

  • This is better than putting a hidden <input hidden value={userId}/> because that will appear in the SSR'd HTML as full text and cannot be encoded. With .bind, we can handle that in the future.
  • This is better than event callbacks onSubmit={(e) => { await updateUser(userId, e.target.formData) }} as this supports progressive enhancement.
  • This is better than re-creating a new action action={async (formData) => { "use server"; return updateUser(userId, formData) }} as inlined "use server" only works in Server Components.

@shuding shuding requested review from a team as code owners September 28, 2023 13:31
@shuding shuding requested review from molebox and steven-tey and removed request for a team September 28, 2023 13:31
sebmarkbage
sebmarkbage previously approved these changes Sep 28, 2023
@kodiakhq kodiakhq bot merged commit fe90b04 into canary Sep 28, 2023
54 of 56 checks passed
@kodiakhq kodiakhq bot deleted the shu/9w1g branch September 28, 2023 16:20
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants