Next.js · Middle · Question 29 of 75
How does <Form> from next/form differ from a plain <form> for a search form?
- ✓Correct answer: With a string
action, it performs a client-side navigation with the query - 2It automatically validates fields against a Zod schema before submitting
- 3It sends data over WebSocket instead of a regular HTTP request
Explanation
<Form action="/search"> turns the fields into searchParams and performs an SPA navigation that keeps the shared layout, instead of a full reload. It prefetches shared UI (e.g. loading.tsx). Without JS it works like a regular form. With a function in action, it behaves like a React form with a Server Action.