NextJS 14 — Server Action and Interactivity
The React ecosystem is evolving, and with that evolution comes new patterns for writing your code! With Server Actions, we are now able to incorporate “backend” code into what is traditionally considered the “client” side of the application. You’re probably familiar with all the meme posts from the launch of this new feature.
Let’s delve into how Server Actions are used in conjunction with the interactivity of your web app.
Server Action
Server Actions are asynchronous functions executed on the server, usable in both client and server components. This is the fundamental concept of Server Actions. But how do they integrate with interactivity?
If you need interactivity, consider converting part of this to a Client Component
Have you ever encountered the following error message? It’s not difficult to resolve, but it requires an understanding of how server and client components interact:
The basics
Using a component with “use client” automatically converts all subsequent components into…