Client component server action call and keep logic
Unanswered
Bluethroat posted this in #help-forum
BluethroatOP
Hi. I', pretty new to NextJs. I'd like to know how to call a server action from a client component FORM, but not using the form's action prop. I mean, I have to send the form data to de server action but then, depending on the response, I'd like to continue with some other client coding logic...
I mean, my question is indeed how to send the form data without using the form's action prop
I mean, my question is indeed how to send the form data without using the form's action prop
5 Replies
You can make a onSubmit event handler and include server actions.
function handleSubmit() {
yourServerAction();
yourOtherJobs();
}
return <form onSubmit={handleSubmit}>
...Red harvester ant
hello @Bluethroat If you are using Next for only Frontend development and for backend, you are using another Framework, You can use Axios
but if you wanna pass the data from the client component to server component you can use cookie
You can store the data using cookie on client components and then use it on server components.
That is it. hope your good luck. 🙂