-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

In this section, we’ll understand what a Server Action is. We’ll then use a Server Action in our form.
In Chapter 7, Server Component Data Fetching and Server Function Mutations, we learned how to mutate data with Server Functions. We can use a Server Function for form submission. In fact, Server Functions used for form submission are so common, they have a special name called Server Actions.
A Server Action can be passed to a form
element in its action
prop as follows:
<form action={serverAction}>
Earlier in this chapter, we used the action
prop for the page path to submit to. We then used the action
prop to implement a client-side submission handler. Here, we are submitting directly to a Server Action. So, the Server Action will need to contain any required page navigation.
A benefit of using a React Server Action for form submission is that it works without JavaScript. This is...