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.
Assign a Server Action to the form's action attribute: <form action={createPost}>.
- On submit, the Server Action is automatically called with the FormData — no client-side JavaScript required (progressive enhancement).
- Inside the action:
const title = formData.get('title'). - Combine with useFormState (React 18) or useActionState (React 19) to track submission state.