MENU
Calls
We can invoke a server action in different places.
We can pass a server action as the event handler of an HTML element in a server component.
Note that we can't define an event handler in an HTML tag in a server component unless the prop is a server action.
Note that we can't define an event handler in an HTML tag in a server component unless the prop is a server action.
We can pass a server action as the event handler of an input element (possibly in an HTML form) in a client component.
To programmatically submit a form in an event handler of an input element in a form, we can use 'e.currentTarget.form?.requestSubmit()'.
To programmatically submit a form in an event handler of an input element in a form, we can use 'e.currentTarget.form?.requestSubmit()'.
We can pass a server action to the 'action' attribute of the form element.
When we do that, a FormData object will be automatically passed to the server action.
When we do that, a FormData object will be automatically passed to the server action.
We can invoke a server action in a useEffect() hook in a client component.
To ensure a server action is indeed running on the server, ensure that when you call console.log(), it logs to the server terminal and not on the browser developer's tools interface (F12).