1. 20
    Refactor POST Handler for Creating a Customer into a Next.js Server Action
    4m 13s

Refactor POST Handler for Creating a Customer into a Next.js Server Action

Share this video with your friends

Send Tweet

We can start utilizing server actions by refactoring our POST handler for creating a customer into a server action.

You will need to add the serverActions: true flag to your next config under the experimental settings.

In this example we will refactor a form that utilizes react-query and react-hook-form that sends a POST request to an API route that we have set up to add customers to.

Server Actions make it easy to grab form data and submit data directly in that action on the server.