Trung BìnhNext.js iconNext.js

Cách sử dụng Server Actions với HTML forms?

Gán Server Action vào form action attribute: <form action={createPost}>.

  • Form submit tự động gọi Server Action với FormData.
  • Không cần JavaScript client-side (progressive enhancement).
  • Trong action: const title = formData.get('title').
  • Kết hợp với useFormState (React 18) hoặc useActionState (React 19) để track state.

Xem toàn bộ Next.js cùng filter theo level & chủ đề con.

Mở danh sách Next.js