Next.js integrates React Actions into the Next.js router, bundler, and caching system, including adding data mutation APIs like revalidateTag and revalidatePath.
Convention
You can enable Server Actions in your Next.js project by enabling the experimental serverActions flag.
next.config.js module.exports = {
  experimental: {
    serverActions: true,
  },
}
Creation
Server Actions can be defined in two places:
Inside the component that uses it (Server Components only)
In a separate file (Client and Server Components), for reusability. You can define multiple Server Actions in a single file.
With Server Components
Create a Server Action by defining an asynchronous function with the "use server" directive at the top of the function body. This function should have serializable arguments and a serializable return value based on the React Server Components protocol.
app/server-component.js export default function ServerComponent() {
  async function myAction() {