Note GET appends data to the URL (visible, cacheable, bookmarkable). POST sends data in the request body (for sensitive data and large payloads). Omitting method defaults to GET.
// Traditional approachfunctionFeedbackForm(){const[message, setMessage]=useState('');const[submitted, setSubmitted]=useState(false);asyncfunctionhandleSubmit(e){
e.preventDefault();awaitsendFeedback(message);setSubmitted(true);setMessage('');}if(submitted)return<p>Thank you for your feedback!</p>;return(<form onSubmit={handleSubmit}><textarea
value={message}
onChange={e =>setMessage(e.target.value)}
required
/><button type="submit">Submit</button></form>);}
Note With onSubmit, always call e.preventDefault() to stop the browser from reloading the page. With React 19 form actions, preventDefault is handled automatically. Both patterns are valid -- actions are newer and reduce boilerplate.
Frequently asked questions
How does HTML & CSS handle form submit?
This task is covered in 2 stacks on this page: HTML & CSS, React. The "Form Element" snippet in HTML & CSS uses `<form action="url" method="GET|POST">`.
Which code does the HTML & CSS example use?
The "Form Element" snippet uses `<form action="url" method="GET|POST">`, from the Forms section of the HTML & CSS cheat sheet.
Which stacks cover "form submit" on this page?
HTML & CSS, React. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Form Element": GET appends data to the URL (visible, cacheable, bookmarkable). POST sends data in the request body (for sensitive data and large payloads). Omitting method defaults to GET.