It's not necessarily a bad idea to make an entire page client-rendered with "use client" if your use case requires it. However, it's generally recommended to use a mix of server and client components to leverage the benefits of both rendering methods.
For your situation with multiple forms, you can create separate client components for each form and use the onSubmit handler within those client components. This way, you can handle form submissions individually without making the entire page a client component.
Here's an example of how you can create a client component for a form:
'use client';
export default function FormComponent() {
const handleSubmit = async (event) => {
};
return (
<form onSubmit={handleSubmit}>
{/* Your form fields and buttons go here */}
</form>
);
}
Then, you can import and use this FormComponent in your page.tsx:
import FormComponent from './FormComponent';
export default function Page() {
return (
<div>
{/* Other components and content */}
<FormComponent />
{/* Other components and content */}
</div>
);
}
This approach allows you to keep your form logic separate and maintainable without making the entire page client-rendered.
Sources:
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: